Skip to content
Advertisement

Tag: django

Django user registration form not showing properly

I am making a Django project where there are two types of users customer and restaurant. Both can register separately. Everything is running fine except that I cannot add CSS class to password field and there are warning showing around password field which I don’t how they are coming. Models.py Forms.py soryy for bad code pasting.Just for clarification class ‘CustomerSignupform’

How to stop autopep8 not installed messages in Code

I’m a new Python programmer using the Mac version of VS Code 1.45.1 to create a Django project. I have the Python and Django extensions installed. Every time I save a Django file, Code pops up this window: I keep clicking the “Yes” button to install the autopep8 extension but this message keeps popping up nevertheless. Is there some trick

Sort a QuerySet by ManyToManyField in Django

I have a model like this: I want to get all Objects of my_model sorted by the number of objects in the foo field. In this Question A friendly Guy from russia says, that you should use django-annontation. I tried the following: and it works fine. Is there any reason I should go the longer way with annotations?? Thx for

Django request.FILES gets name, filename but not file (blob)

I’m trying to send an audiofile via a POST request to the server (aws, ec2) and I’m using Django, but my request.FILES doesn’t receive the blob file, but it DOES receive the key and the filename. Everything worked fine when I ran this on localhost. How can I get the file? I’m enabling my website on chrome://flags/#unsafely-treat-insecure-origin-as-secure, so that I

How to use Django session variable in models.py

I wanna use the Django session variable on models.py file. How can I do it? I want to get the user’s Pincode/zip and have to run a query using that. I need to get Pincode from the session. Answer In your model method you don’t have access to the request so you do not have access to the session. One

‘microsecond’ is an invalid keyword argument for replace()

I am using Django 2.0+ and am attempting to just plug in the existing password reset function into my website. If the email does not exist, it successfully submits. If it DOES exist, I get this error: ‘microsecond’ is an invalid keyword argument for replace() I never touched any of the backend code for this function so I would assume

IntegrityError NOT NULL constraint failed: – in validating form missing user id (foreing key of anothermodel)

Previous title: Unable to import ‘misaka’ – Django I am following a tutorial about how to build a social network. I run into this error: IntegrityError at /posts/new/ NOT NULL constraint failed: posts_post.user_id Complete traceback (please note the lines in bold): The lines in bold are pointing to these two pieces of code: 1: In my_projectpostsviews.py in form_valid: 2: In

Advertisement