Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to view specific fields from db of two tables into html table in django?
how to combine specific fields in two tables in dbsqlite into html table in python django.how to call values into table <tbody id="tableSearch"> {% for instance in experiment_detail %} {% for instance in project_detail %} <tr> <!-- <td>{{ instance.id }}</td> --> <td>{{ instance.Experiments_name }}</td> <td>{{ instance.Experiments_remarks }}</td> <td>{{ instance.ProjectName }}</td> <td> class Experiments(models.Model): Experiments_name = models.CharField(max_length=100) Experiments_status = models.CharField(max_length=100) Experiments_project_id = models.ForeignKey('Project', on_delete=models.CASCADE) Experiments_testRatio = models.FloatField(default=0.0) Experiments_remarks = models.CharField(max_length=100,default='') class Project(models.Model): ProjectName = models.CharField(max_length=100) -
Django channels update playerlist on disconnect
I'm making a chat room with django-channels(websocket functionality). I have Room and Artist models and, I have two forms HostRoom and JoinRoom. I have a player list on the left of the screen. I'm able to update the player list in a room when a new user enters by broadcasting new playerlist to room. (running broadcast_msg_to_chat by catching m2m changed) However, I couldn't find a way to update the room player list when one of the artist leaves the room, I also need to delete disconnected artist instance from the room instance. I tried to update in onDisconnect using self.nickname inside consumer, but it deleted the the nickname of the last person who entered the room. How can I handle that? #forms.py class HostRoomForm(forms.ModelForm): class Meta: model = Artist fields = ['nickname', ] labels = { 'nickname': _('nickname'), } class JoinRoomForm(forms.ModelForm): temp_room_code = forms.CharField(max_length=6, min_length=6) class Meta: model = Artist fields = ['nickname', 'temp_room_code', ] labels = { 'nickname': _('nickname'), } #models.py class Room(models.Model): name = models.CharField(max_length=6) # make unique artists = models.ManyToManyField('Artist') active = models.BooleanField(default=False) class Artist(models.Model): nickname = models.CharField(max_length=30, default='') def __str__(self): return f'{self.nickname}' def artists_changed(instance, *args, **kwargs): artists_count = instance.artists.count() # broadcast playerlist to room if artists_count … -
Mac OS Big Sur update causing pip install requirements for django 1.11 with cffi error
Mac OS Big Sur update causing pip install requirements for django 1.11 with cffi error. How can I resolve this ? Running setup.py install for cffi ... error ERROR: Command errored out with exit status 1: command: /Users/axil/Documents/project/projectdotcom/projectdotcomenv_v2/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gp/2f22kt6s75d8tf653xq_5rfh0000gn/T/pip-install-nsm19ufc/cffi_73cb07cbfd52456caf370009aa7e0938/setup.py'"'"'; __file__='"'"'/private/var/folders/gp/2f22kt6s75d8tf653xq_5rfh0000gn/T/pip-install-nsm19ufc/cffi_73cb07cbfd52456caf370009aa7e0938/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/gp/2f22kt6s75d8tf653xq_5rfh0000gn/T/pip-record-y3_9oop2/install-record.txt --single-version-externally-managed --compile --install-headers /Users/axil/Documents/project/projectdotcom/projectdotcomenv_v2/include/site/python3.8/cffi cwd: /private/var/folders/gp/2f22kt6s75d8tf653xq_5rfh0000gn/T/pip-install-nsm19ufc/cffi_73cb07cbfd52456caf370009aa7e0938/ Complete output (65 lines): running install running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/backend_ctypes.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/error.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/setuptools_ext.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/cffi_opcode.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/vengine_gen.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/model.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/ffiplatform.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/api.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/vengine_cpy.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/commontypes.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/lock.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/recompiler.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/cparser.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/verifier.py -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/_cffi_include.h -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/parse_c_type.h -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/_embedding.h -> build/lib.macosx-10.9-x86_64-3.8/cffi copying cffi/_cffi_errors.h -> build/lib.macosx-10.9-x86_64-3.8/cffi running build_ext building '_cffi_backend' extension creating build/temp.macosx-10.9-x86_64-3.8 creating build/temp.macosx-10.9-x86_64-3.8/c gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/local/Cellar/libffi/3.3/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi -I/Users/axil/Documents/project/projectdotcom/projectdotcomenv_v2/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c c/_cffi_backend.c -o build/temp.macosx-10.9-x86_64-3.8/c/_cffi_backend.o c/_cffi_backend.c:4197:31: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] … -
no such column: ecomapp_firstsliderdata.category_id why the category data is not deleting and showing this error in django
when i try to open column in no such column category_id why this is showing and also i'm not able to delete category list from DB my models.py class FirstSliderData(models.Model): image = models.ImageField() title = models.TextField(max_length=500) desc = models.TextField(max_length = 5000 ,null=True,blank=True) category = models.ForeignKey(Category , on_delete=models.CASCADE , default=1) brandName = models.TextField(max_length = 100,default='',null=True,blank=True) class TopList(models.Model): image = models.ImageField(upload_to='ProductImg') title = models.TextField(max_length=500) discountpercentage = models.IntegerField(blank=True,null=True) discountPrice = models.IntegerField(blank=True,null=True) brandName = models.TextField(max_length = 100 , default='',null=True,blank=True) desc = models.TextField(max_length=5000 ,null=True,blank=True) finalprice = models.IntegerField(blank=True,null=True) category = models.ForeignKey(Category , on_delete=models.CASCADE , default=1) @staticmethod def get_products_by_id(ids): return Product.objects.filter(id__in =ids) @staticmethod def get_all_products(): return Product.objects.all() @staticmethod def get_all_products_by_categoryid(category_id): if category_id: return Product.objects.filter(category = category_id) else: return Product.get_all_products() class Category(models.Model): name = models.CharField(max_length=20) @staticmethod def get_all_categories(): return Category.objects.all() def __str__(self): return self.name my admin.py file also the category list is not deleting from db it shows same error again when i try to delete like listed product i'm getting same errors from .models import FirstSliderData , TopList ,Category @admin.register(FirstSliderData) class FirstsliderModelAdmin(admin.ModelAdmin): list_display=['id','image','title' ,'category'] @admin.register(Category) class CategoryAdmin(admin.ModelAdmin): list_display = ['name'] -
Django RetrieveAPIView class with pagination
I have following class class CommentRetrieveView(generics.RetrieveAPIView): queryset = Comment.objects.all() serializer_class = CommentSerializer pagination_class = PageNumberPagination permission_classes = (permissions.IsAuthenticatedOrReadOnly,) As a pagination class i set PageNumberPagination, but when i try to http://127.0.0.1:8000/api/comments/6fc515bb-295a-4191-8255-da7f8fe7976e my result is without pagination { "id": "6fc515bb-295a-4191-8255-da7f8fe7976e", "comment": "test comment", "name": "Test", "age": 25, "comment_date": "2021-01-10T10:07:45.549207Z", "person": "718b309c-864d-4c26-a80e-2e744ac3102a"} The default pagination class in settings is 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination' How to correctly use pagination in RetrieveAPIView? -
How could I create many radio inputs with for loop?
Here's my code: {% for answer in value %} <div class="answer"> <input type="radio" name="answer-checkbox" value="{{ answer.id }}"> {{ answer }} </div> {% endfor %} I want to create multiple sets of questions and answers, within each set only one answer could be selected at a time, how could I do this? -
How to not submit a form unless search is one of the options (django + HTML) [duplicate]
So I have the following code: <input autocomplete="off" type="search" list="liss" name="q" id="id_q" placeholder="Search"> <datalist id="liss"> <option value="one">Value 1</option> <option value="two">Value 2</option> <option value="three">Value 3</option> <option value="four">Value 4</option> <option value="five">Value 5</option> <option value="six">Value 6</option> </datalist> And it all works fine. The only thing I want it to do is to not let the user submit the form unless the input value is one of the options. How can I do that? -
A way to filter models for ModelChoiceField in Wagtail
Let's say I have a ForeignKey field in my model. class MyModel(StatusModel): site = models.ForeignKey('wagtailcore.Site', related_name='test_field', on_delete=models.CASCADE) panels = [ FieldPanel('site') ] Looks like Wagtail creates ModelForms by itself, but I need to filter models that make it to the dropdown list on my editing page. How can I do it? -
How do I include username (<str:username>) in my react native Endpoint
Please im learning react native and I am stuck, my problem is that I need to be about to use something like this in my react native (API): const endpoint = "/users/<username>/"; const getUser = () => client.get(endpoint); So the gist is, I want to dynamically pass the user's username in there, because thats the only way to get the details from the backend (REST API), When i use POSTMAN and get this http://127.0.0.1:8000/api/users/*username* it returns the needed data, but when I try that, even putting the username manually it doesnt work . Secondly, is there a way to get the user's username from jwt token and pass it into the react native endpoint. Id share my code below, Please bear with me: API URL PATH IN DJANGO: path('<str:username>/', profile_detail_api_view), path('<str:username>/follow', profile_detail_api_view), API CALL IN REACT NATIVE: import client from "./client"; const endpoint = "/users/que/"; (FOR INSTANCE HERE IM PASSING THE USERNAME DIRECTLY TO TEST) const getUser = () => client.get(endpoint); export default { getUser, }; PAYLOAD ON JWT SAMPLE: { "token_type": "access", "exp": 1611483456, "jti": "47907077556234bd9b6a9fa330f5ee", "user_id": 2 } I have tried a direct endpoint (blog) and it works, but that user part doesnt even though its the same … -
How to modify the form field types in the django CreateView form
I have a model that has a couple of date fields. I am using the CreateView along with a template. In the template, I am doing fairly standard code {% extends 'instructor_base.html' %} {% load crispy_forms_tags %} {% block title %} New Section {% endblock %} {% block content %} <h1>New Section</h1> <form method="post"> {% csrf_token %} {{ form|crispy }} <button class="btn btn-success ml-2" type="submit">Save</button> </form> {% endblock %} However, when the form displays, the two date fields in the model are displayed as text boxes in the form. I would like them to display as date type. After several hours of going through documentation and tutorial sites, I can not figure out how to accomplish this. Everything I find is on how to override CreateView itself and not the form that goes with it. Any help with this would be greatly appreciated. -
Nginx stopped and failed to restart - open() "/run/nginx.pid" failed
I am running my django apis, deployed on Ubuntu 18, on Nginx and running via Supervisor. I am using Certbot for SSL certs and this is the only web service running on this webserver. No other websites are deployed here. The APIs went down today and nginx stopped working. I am not able to recreate why this happened, it had to be manually restarted. I have faced this once before and had similar error messages in the logs. Following are the nginx error logs. 2021/01/09 15:55:39 [crit] 9453#9453: *1331764 SSL_do_handshake() failed (SSL: error:1420918C:SSL routines:tls_early_post_process_client_hello:version too low) while SSL handshaking, client: <CLIENT IP ADDRESS>, server: 0.0.0.0:443 2021/01/09 20:39:55 [error] 9453#9453: *1337050 upstream prematurely closed connection while reading upstream, client: <CLIENT IP ADDRESS>, server: , request: "PUT /api/v1/APIURL/ HTTP/1.1", upstream: "http://127.0.0.1:8081/api/v1/APIURL", host: "<URL>", referrer: "<URL>" 2021/01/09 20:40:12 [error] 9453#9453: *1337057 upstream prematurely closed connection while reading upstream, client: <CLIENT IP ADDRESS>, server: , request: "PUT /api/v1/APIURL/ HTTP/1.1", upstream: "http://127.0.0.1:8081/api/v1/APIURL", host: "<URL>", referrer: "<URL>" 2021/01/09 20:41:02 [error] 9453#9453: *1337064 upstream prematurely closed connection while reading upstream, client:<CLIENT IP ADDRESS>, server: , request: "PUT /api/v1/URL/ HTTP/1.1", upstream: "http://127.0.0.1:8081/api/v1/URL/", host: "URL", referrer: "URL" 2021/01/10 03:51:29 [notice] 32527#32527: signal process started 2021/01/10 03:51:29 [error] 32527#32527: open() … -
How to include related models Django
I have 3 models: class ImageAlbum(models.Model): def default(self): return self.images.filter(default=True).first() def thumbnails(self): return self.images.filter(width__lt=100, length_lt=100) class Image(models.Model): name = models.CharField(max_length=255) image = models.ImageField(upload_to='images/') default = models.BooleanField(default=False) width = models.FloatField(default=100) length = models.FloatField(default=100) album = models.ForeignKey(ImageAlbum, related_name='images', on_delete=models.CASCADE) class Product(models.Model): title = models.CharField(max_length=300) price = models.IntegerField() description = models.TextField(max_length=2000, help_text="This is the description of the product") images = models.OneToOneField(ImageAlbum, related_name='model', on_delete=models.CASCADE) When I'm selecting product models Product.objects In the Product field images I'm having only the primary key of album. I want to get related ImageAlbum and all related Image for each ImageAlbum when I'm selecting Product model. Appreciate any help, thanks. -
Implement Page/Google-Login Counter with Django and Cookies?
I want to keep track: 1.) How many visitors went on my homepage 2.) How many logged in with the Google button For now I simply created with python a django-model: id url visitor_counter google_login_counter Everytime someone visits a page with the url x, it increases the visitor_counter. Everytime someone logs in with Google on the page x, it increases the google_login_counter. So far, so good, but now I have the problem, that if the user reloads the page, the counter increases again. I want to prevent this and wanted to ask what is the best solution? I was thinking about using cookies to check, if the user was already on the page? Is there a better solution or should I go with cookies? -
AttributeError: 'NoneType' object has no attribute 'append' error in Django project
I'm trying to store a list of items in a Django session. The code is below, def index(request): today = date.today() d = today.strftime("%A, %B %d") if request.method == 'POST': item = request.POST.get('newItem') items = request.session.get('items',[]) request.session.modified = True request.session['items'] = items.append(item) return render(request, 'todo/index.html', {'kindOfDay':d, 'newListItems': request.session.get('items', list())}) I get the following error, AttributeError: 'NoneType' object has no attribute 'append' I have included the below two lines in settings.py SESSION_SAVE_EVERY_REQUEST = True SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" I'm a beginner and any help would be appreciated. -
SSO with Django for Matrix
I have a working Django (3.1) website and I'm trying to setup a Matrix Server (using Synapse) for the users. How can I Setup Single Sign On for synapse (It supports SAML, CAS and OIDC) where only the users of my website could login to it? I already saw Django OIDC Provider, but I didn't figure how to set it up there. Any Idea for making it easier? -
using Dockerfile as host for python development
I'm developing a Django application and using Pipenv to manage the python virtual environment. There are few dependencies that are causing the problem on installation in the host operating system. These issues are different for different operating systems (Mac, Linux, windows). I have created a Dockerfile with the following content FROM python:3.7.6-slim # Create a group and user to run our app ARG APP_USER=anychat RUN groupadd -r ${APP_USER} && useradd --no-log-init -r -g ${APP_USER} ${APP_USER} # Install packages needed to run your application (not build deps): RUN set -ex \ && RUN_DEPS=" \ libpcre3 \ mime-support \ libmagic1 \ default-libmysqlclient-dev \ inkscape \ libcurl4-nss-dev libssl-dev \ " \ && seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \ && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \ && pip install pipenv \ && mkdir /app/ \ && mkdir /app/config/ \ && mkdir /app/scripts/ \ && mkdir -p /static_cdn/static_root/ \ && chown -R ${APP_USER} /static_cdn/ WORKDIR /app/ COPY Pipfile Pipfile.lock /app/ RUN set -ex \ && BUILD_DEPS=" \ build-essential \ libpcre3-dev \ libpq-dev \ " \ && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ && pipenv install --deploy --system # Copy your application app to the container … -
How could I create many db objects with python for loop?
I want to create multiple db objects with for loop: if request.method == 'POST': answers_data = InterestAnswer.objects.all() for userAns in answersIDs: for answerObj in answers_data: cur = answerObj.id if userAns == cur: userAnswered = UserAnswer(answer=answerObj, user= request.user, is_checked=True) userAnswered.save() and here's my model: class UserAnswer(models.Model): is_checked = models.BooleanField(default=False) answer = models.ForeignKey(InterestAnswer, max_length=64, on_delete=models.CASCADE) user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) from html page I am getting a bunch ids of answers and for each of these ids I want to create a db object, am I doing it correctly? I am getting this error: UNIQUE constraint failed: account_useranswer.user_id When my user is completing this quiz for the first time only the first id is used to create object in database, and the others are disappearing. When the same user tries to complete the same quiz I am getting this error I mentioned before. What's the problem? -
JS not working in Django Templates (addEventListener and getPropertyValue
I have a javascript that works when I run it outside of Django; however, when I try to run it within my Django Project, I get an error saying "Uncaught TypeError: Cannot read property 'addEventListener' of null" and an error saying "Uncaught SyntaxError: Identifier 'getPropertyValue' has already been declared. I was wondering if JS works the same within Django Templates as it does it normal html. -
How to automatically create a new entry in postgresql table weekely
I am creating a weekly progress checking website in which user can add weekly progress for which i have created a new table called progress which has a foreign key user_id now I want to add an entry to this progress table automatically after every week for that particular user in which he can save current week goals, target etc. -
ERROR (spawn Error) when trying to start my supervisor conf
WebAPP_celery.conf file ; ================================== ; celery worker supervisor example ; ================================== ; the name of your supervisord program [program:webappcelery] ; Set full path to celery program if using virtualenv command=/home/brennan/webapp/env/bin/celery worker -A WebAPP --loglevel=INFO ; The directory to your Django project directory=/home/brennan/webapp/ ; If supervisord is run as the root user, switch users to this UNIX user account ; before doing any processing. user=brennan ; Supervisor will start as many instances of this program as named by numprocs numprocs=1 ; Put process stdout output in this file stdout_logfile=/var/log/celery/webapp_worker.log ; Put process stderr output in this file stderr_logfile=/var/log/celery/webapp_worker.log ; If true, this program will start automatically when supervisord is started autostart=true ; May be one of false, unexpected, or true. If false, the process will never ; be autorestarted. If unexpected, the process will be restart when the program ; exits with an exit code that is not one of the exit codes associated with this ; process’ configuration (see exitcodes). If true, the process will be ; unconditionally restarted when it exits, without regard to its exit code. autorestart=true ; The total number of seconds which the program needs to stay running after ; a startup to consider the start … -
form doesn't submit productbacklogs to database
#model.py from django import forms from projectapp.models import Project class ProjectForm(forms.ModelForm): class Meta: model = Project exclude=('proId',) fields = ['proTitle'] #forms.py from django import forms from productbacklogapp.models import Productbacklog from projectapp.models import Project class ProductbacklogForm(forms.ModelForm): class Meta: model = Productbacklog exclude=('pbId','project') fields=['pbTitle'] #views.py def productbacklogall(request): Projectinlineformset = inlineformset_factory(Project, Productbacklog, form=ProductbacklogForm) if request.method=='POST': backlogform = ProductbacklogForm(request.POST) b=backlogform.save(commit=False) b.save() formset=Projectinlineformset(request.POST,request.FILES,instance=b) if formset.is_valid(): formset.save() messages.success(request, ('new productbacklog added')) return redirect('productbacklogall') else: pb_all=Productbacklog.objects.all() return render(request,'productbacklogall.html',{'pb_all':pb_all}) -
Force Close App Browser Django ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
I'm a beginner in Django and I'm trying to test the registration form that I created on my mobile browser, it's working fine, but every time I force close the browser application on my phone or my phone screen timed out I get [WinError 10054] I have this on my settings.py ALLOWED_HOSTS = ['myip'] and I run my server like this python manage.py runserver 0.0.0.0:8000 Error that I get: ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host Is there something I need to configure, so this error won't show up? Thank you. -
JQuery disable submit button till form is completely filled
I am trying to implement a jquery function to diable submit button till all values are filled please help as I seem not to find a solution to it..Where am I going wrong? Here is the html: <form action="{% url 'register' %}" id="registerform" class="sign-up-form" method="POST"> {% csrf_token %} <h2 class="title">Sign up</h2> <div class="row"> <div class="col-md-6"> <div class="input-field"> <i class="fas fa-user"></i> <input type="text" name="firstname" placeholder="First name"/> </div> </div> <div class="col-md-6"> <div class="input-field"> <i class="fas fa-user"></i> <input type="text" name="secondname" placeholder="Second name"/> </div> </div> <div class="col-md-6"> <div class="input-field userfield"> <i class="fas fa-user"></i> <input type="text" id="id_username" name="username" placeholder="Username"/> </div> </div> <div class="col-md-6"> <div class="input-field emailfield"> <i class="fas fa-envelope"></i> <input type="email" id="id_email" name="email" placeholder="Email"/> </div> </div> <div class="col-md-6"> <div class="input-field"> <i class="fas fa-lock-open"></i> <input type="number" name="idno" placeholder="ID/Passport Number"/> </div> </div> <div class="col-md-6"> <div class="input-field"> <i class="fas fa-user-ninja"></i> <input type="text" name="nationality" placeholder="Nationality"/> </div> </div> <div class="col-md-6"> <div class="input-field passfield"> <i class="fas fa-lock"></i> <input type="password" id="password" onkeyup="checkPasswordStrength();" name="password" placeholder="Password"/> </div> </div> <div class="col-md-6"> <div class="input-field cpassfield"> <i class="fas fa-lock"></i> <input type="password" id="cpassword" onkeyup="cpassword();" placeholder="Confirm Password"/> </div> </div> </div> <input type="submit" id="register" class="btn" style="background-color: #5995fd;!important;" value="Sign up" disabled/> <p class="copy-text">&copy;2020. All Rights Reserved</p> <h3 class="copy-text"> Kenya Airways</h3> </form> and the javascript: <script> //disable submit button (function () { … -
syntactic problem with list display in django
I'm learning django through a tutorial on youtube, and even faithfully following the video, this problem continues, how to solve? enter image description here -
no such column: ecomapp_toplist.desc can anyone find error why it is showing in django
why no such column: ecomapp_toplist.desc is showing because i make desc in model and register it also . class TopList(models.Model): image = models.ImageField(upload_to='ProductImg') title = models.TextField(max_length=500) discountpercentage = models.IntegerField(blank=True,null=True) discountPrice = models.IntegerField(blank=True,null=True) brandName = models.TextField(max_length = 100 , default='',null=True,blank=True) finalprice = models.IntegerField(blank=True,null=True) category = models.ForeignKey(Category , on_delete=models.CASCADE, default=1) desc = models.TextField(max_length=5000) class Category(models.Model): name = models.CharField(max_length=20) @staticmethod def get_all_categories(): return Category.objects.all() my admin.py by @admin.register(TopList) class TodoListModelAdmin(admin.ModelAdmin): list_display=['id','image','title','category' ]