Skip to content
Advertisement

Tag: django

TypeError: create_superuser() missing 1 required positional argument: ‘profile_picture’

I get the following error after adding the profile_picture field: This profile_picture field is an “ImageField” set as “Null = True”. I have tried the following: def create_user(…., profile_picture=None, ….). It didn’t work. and the error occurs only in command prompt when i create superuser from there. Here is my models.py Answer Well, you need to create the create_superuser function

Django channels: No module named ‘asgiref.sync’

I am following this guide for channels tutorial (https://media.readthedocs.org/pdf/channels/latest/channels.pdf) and after adding channels to top of INSTALLED APPS, adding ASGI_APPLICATION = ‘mysite.routing.application’ to my setting file and creating following routing.py: I am getting this error after running python manage.py runserver: ModuleNotFoundError: No module named ‘asgiref.sync’ I have following versions of libraries: Can someone help me ? I am new to

Django: Get previous value in clean() method

I have a model CustomModel with an IntegerField. When I create a new instance of CustomModel in the admin, I have to do validation, so I use the clean method and have access to the value with. My problem: When I change the instance of CustomModel, I only have access to the new, changed value but not to the original

django-rest-framwork got AttributeError when attempting to get a value for field

I want to get all prodcut table values with join product_ratings table. I did somthing like this but this code give me AttributeError. So I did product_ratings = ProductRatingSerializer(many=True) in product serializer and used this value in the field, but it’s not working: The full error message: view : its serializer classes: related model class : Answer Default reverse lookup

python manage.py migrate: No module named ‘muypicky.base’

Background: I’m taking a beginners Django course and I’ve run into an issue. The following command isn’t working in Terminal. Running on Mac Virtual environment Taking UDEMY Course: try-django-v1-11-python-web-development Command: python manage.py migrate Answer After going through your files, i found that you haven’t imported local.py and production.py in your __init__.py add the following code to __init__.py file inside settings

After login the `rest-auth`, how to return more information?

I use django-rest-auth in my Django project. After login the rest-auth/login/, how to return more information? In the rest-auth/login/, when I login the user, it returns a key. I want to also return the user’s information, how can I get this? Answer At last, I get my solution: In the project settings.py, add the TOKEN_SERIALIZER like bellow: Now I get

Pass argument to Django form

There are several questions on stackoverflow related to this topic but none of them explains whats happening neither provides working solution. I need to pass user’s first name as an argument to Django ModelForm when rendering template with this form. I have some basic form: Here’s my sample class-based view: What do I pass to MyForm when initialising it and

Advertisement