Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
What does the @ symbol mean in a Django URL?
In urls.py there is a line: path('profile/view/@<username>/', main.views.foo.profile, name='fooprofile'), What does the @ mean in @<username> ? Where can I find this in the Django documentation? -
invalid literal for int() with base 10: 'Moniczka' occured when I tried to register new user in REST API
I created registration API view using Django REST API and when I tried to use endpoint, after POST I could have seen the error: invalid literal for int() with base 10: 'Moniczka'. I've checked RegisterSerializer, RegisterAPI view and url and I can't see any mistakes. Mayby some of you can help me. Here is my serializer class: class RegisterSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('id', 'username', 'email', 'password') extra_kwargs = {'password': {'write_only': True}} def create(self, validated_data): user = User(validated_data['username'], validated_data['email'], validated_data['password']) return user Here is my views.py: # Register API class RegisterAPI(generics.GenericAPIView): serializer_class = RegisterSerializer def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.save() return Response({ "user": UserSerializer(user, context=self.get_serializer_context()).data, "token": AuthToken.objects.create(user)[1] }) And finally urls.py: urlpatterns = [ path('register/', RegisterAPI.as_view(), name='register'), ] I hope that one of you could help me :( -
how to get username as initial value on forms in django
I would like to get initial value on the following form but i get error : name 'user' is not defined. I don't know how to get user.username. class InvoiceForm(ModelForm): date = forms.DateField(widget=DateInput) user = forms.CharField(initial={"username": user.username}) class Meta: model = Invoice fields = "__all__" and the view to create the invoice is : class InvoiceCreate(CreateView): form_class = InvoiceForm model = Invoice template_name = "sales/invoice_form.html" def get_success_url(self, request): return reverse_lazy('invoice_details', kwargs={'pk' : self.object.pk}) def get(self, request, *args, **kwargs): self.object = None form_class = self.get_form_class() form = self.get_form(form_class) formset = InvoiceItemFormSet() products = list(Product.objects.values()) return self.render_to_response( self.get_context_data(form=form,formset=formset, products=products)) def post(self, request, *args, **kwargs): self.object = None form_class = self.get_form_class() form = self.get_form(form_class) formset = InvoiceItemFormSet(self.request.POST) if (form.is_valid() and formset.is_valid()): return self.form_valid(form, formset) else: return self.form_invalid(form, formset) def form_valid(self, form, formset): self.object = form.save() formset.instance = self.object formset.save() try: addmore = self.request.GET["addmore"] if addmore == "True": return redirect("update_invoice", pk=self.object.id) except Exception as e: pass return HttpResponseRedirect(self.get_success_url()) def form_invalid(self, form, formset): return self.render_to_response(self.get_context_data(form=form, formset=formset)) I would like to get initial value on the following form but i get error : name 'user' is not defined. I don't know how to get user.username. -
How do I populate my OrderItem model with fields from my Product model in Django?
I am using ModelViewSet and serializers to view my orders and products. So in my admin panel for my Product model I already added product, price, and price per pound. So eg. (banana, 2.00, 2.99). class Product(models.Model): name = models.CharField(max_length=70) price = models.DecimalField(max_digits=10, decimal_places=2) price_per_pound = models.DecimalField(max_digits=10, decimal_places=2, default=0.00) category = models.ForeignKey(Categories, related_name='products', on_delete=models.CASCADE) def __str__(self): return self.name In my OrderItem model I can select the product that is available, but when I select the banana I want the price and price_per_pound fields to auto populate with what I have in my Product model eg.(2.00, 2.99). How would I go about this? class OrderItem(models.Model): order = models.ForeignKey(Order, related_name='items', on_delete=models.CASCADE) product = models.ForeignKey(Product, related_name='+', on_delete=models.CASCADE) price = models.DecimalField(Product.price) //Tried this way, but doesn't work. price_per_pound = models.ForeignKey(Product, related_name='product_price_per_pound', on_delete=models.CASCADE) //this still only give me the field names of my product quantity = models.PositiveIntegerField(default=1) ready = 1 on_its_way = 2 delivered = 3 STATUS_CHOICES = ( (ready, 'ready'), (on_its_way, 'on its way'), (delivered, 'delivered'), ) status = models.SmallIntegerField(choices=STATUS_CHOICES) -
'Profile' object has no attribute 'save' Django error
So I created a Profile model to have a OneToOne field to the the base django "User" model and I am trying to make it so a profile model is created every time a user model is created. Basically every time someone goes through the registration process and creates a user a profile model is also created that is linked the user model that was just created. here is my Profile model in models.py: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='user') bio = models.CharField(max_length=100, default="") tricks = models.ManyToManyField("Trick") here is my views.py file for the signup field: def signup(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) profile = Profile(user=User.objects.get(username=username)) profile.save() login(request, user) return redirect("home") else: form = UserCreationForm() return render(request, 'registration/register.html', {'form': form}) Every time I complete the registration form to create a new user I get the error: AttributeError: 'Profile' object has no attribute 'save'. The thing that is confusing me is that if I create a profile object in the interactive shell Django provides It allows me to save it with the same exact 'save()' command so why is it throwing an error here, and … -
Facing issue with BASE_DIR in Django
I am working with Django. Facing issue while using BASE_DIR because earlier this was like - BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file))) and now after the update - - BASE_DIR = Path(__file__).resolve().parent.parent Can someone help as I am using static files in my project as below - STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR / 'static', STAICFILES_DIRS = [ BASE_DIR, 'ecom/static', ] earlier than this I was using BASES_DIR as - STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') STAICFILES_DIRS = [ os.path.join(BASE_DIR, 'ecom/static'), ] -
form.save() deletes all user data on one form field
I am trying to build a profile edit view in my Django app. However, I noticed a strange behavior. After editing the program field for my user model. After saving the form in the view using form.save() all my user data gets deleted. Meaning my username, first name, last name,.... all gets set to null. Below is my EditProfileForm: class EditProfileForm(UserChangeForm): username = forms.CharField( max_length=255, min_length=1, required=False, validators=[username_regex], widget=forms.TextInput( attrs={ "placeholder": "Username", "class": "form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ) ) first_name = forms.CharField( max_length=255, min_length=1, required=False, validators=[alphanumeric], widget=forms.TextInput( attrs={ "placeholder": "First name", "class": "form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ) ) last_name = forms.CharField( max_length=255, min_length=1, required=False, validators=[alphanumeric], widget=forms.TextInput( attrs={ "placeholder": "Last name", "class": "form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ) ) university = forms.ChoiceField( label='University', required=False, choices = UNIVERSITY_CHOICES, widget=MySelect( attrs={ "class":"form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ), ) email = forms.EmailField( required=False, widget=forms.EmailInput( attrs={ "placeholder": "Email", "class": "form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ) ) bio = forms.CharField( required=False, widget=forms.Textarea( attrs={ "placeholder":"Enter something about yourself", "class": "form-control mt-3", "rows":"5", } ) ) program = forms.CharField( required=False, widget=forms.TextInput( attrs={ "placeholder":"What are you studying?", "class": "form-control border-top-0 border-left-0 border-right-0 rounded-0 mb-2", } ) ) … -
How do I access a dictionary key in a contex variable that gets passed from a ListView to a template?
I want to access a dictionary key in a context variable that gets passed from a ListView to a template. Here is my views.py file: class ListJobListingsView(generic.ListView): template_name = 'employers/list_joblistings.html' model = JobListing context_object_name = 'joblistings_list' def get_queryset(self): object_list = JobListing.objects.filter(admin_approved=True).order_by('job_title')[:5] category = self.request.GET.get("category", None) job_title = self.request.GET.get("job_title", None) if category and not job_title: object_list = self.model.objects.filter() #TODO: make the query based on foreign key if job_title and not category: object_list = self.model.objects.filter(name__contains=job_title) if job_title and category: object_list = self.model.objects.filter(name__contains=job_title) #TODO: make the query based on foreign key return object_list def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super().get_context_data(**kwargs) # Add in a QuerySet of all the category choice context['categories'] = Category_JobListing._meta.get_field("category").choices return context Note how I have added the context['categories'] to my context in the get_context_data method. In my list_joblistings.html template, I have: {% if joblistings_list %} <form method="get" action="{% url 'employers:list_joblistings' %}"> <p>Filter by category:</p> <select name="category"> {% for key, value in joblistings_list.categories.items %} <option value="{{ key }}"> {{ value }} </option> {% endfor %} </select> <p>Search by job title: <input type="text" name="job_title"/></p> <p><input type="submit" name="Submit" value="submit"/></p> </form> <p> joblistings_list.categories.items = {{ joblistings_list.categories.items }} </p> <p> joblistings_list = {{ joblistings_list }} … -
Do you need a build tool for Django Application to use GitHub Actions?
I am new to Django/Github actions and wanted to know, if you need a build tool like PyBuilder/Setuptools/etc. to have a CI Pipeline with Github actions for a Python Django app, or is a virtual environment and pip enough? -
Gunicorn/GEvent + Django: Do I need some sort of pool?
I'm reading a few guides on setting Django up with Gevent and Gunicorn and everyone seems to touch on considering a pool like psyco_gevent. It's unclear to me if this is a requirement, so I wanted to get a definitive answer on this. If I'm running gunicorn like so with no other gevent usage: gunicorn --workers=4 --log-level=debug --timeout=90 --worker-class=gevent myapp.wsgi Do I need something like psyco_gevent? -
Django Authentication fails
I try to create the login page for my application but I can't authenticate the user no matter what I try for a week now. Here is my code: views.py from django.shortcuts import render, HttpResponseRedirect from django.urls import reverse from django.contrib.auth import login, logout, authenticate from django.db import IntegrityError from .models import User def login_view(request): if request.method == "POST": username = request.POST["username"] password = request.POST["password"] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return HttpResponseRedirect(reverse("index")) else: return render(request, "login.html", {"message": f"{user}"}) return HttpResponseRedirect(reverse("login")) else: return render(request, "login.html") models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): pass urls.py from django.urls import path from .views import index, login_view, register urlpatterns = [ path("", index, name="index"), path("login", login_view, name="login"), path("register", register, name="register") ] login.html {% extends "layout.html" %} {% block title %}Login{% endblock %} {% block content %} <div class="fluid-container"> <h3 id="header">Login</h3> {% if message %} <h4>{{ message }}</h4> {% endif %} <form method="post" class="form" action="{% url 'login' %}">{% csrf_token %} <div class="form-group"> <input class="form-control" type="text" name="username" placeholder="Username" /> </div> <div class="form-group"> <input class="form-control" type="password" name="password" placeholder="Password" /> </div> <div class="form-group"> <input class="btn btn-primary" type="submit" value="Login" /> </div> </form> <p>Don't have an account? <a href="{% url … -
Django 'method' object is not subscriptable
I have a problem with django, I get name from Html index page and after that ı want to request data. And after ı want to reach that data with gettin html name. from flask import Flask,render_template,request import requests api_key = "35c1fbfe2a35fd3aaf075e7394bf8855" url = "http://data.fixer.io/api/latest?access_key="+api_key app = Flask(__name__) @app.route("/" , methods = ["GET","POST"]) def index(): if request.method == "POST": firstCurrency = request.form.get("firstCurrency") # EURO secondCurrency = request.form.get("secondCurrency") # TRY amount = request.form.get("amount") #20 response = requests.get(url) #app.logger.info(response) infos = response.json firstValue = infos["rates"][firstCurrency] secondValue = infos["rates"][secondCurrency] result = (secondValue / firstValue) * float(amount) currencyInfo = dict() currencyInfo["firstCurrency"] = firstCurrency currencyInfo["secondCurrency"] = secondCurrency currencyInfo["amount"] = amount currencyInfo["result"] = result #app.logger.info(infos) return render_template("index.html",info = currencyInfo) else: return render_template("index.html") if __name__ == "__main__": app.run(debug = True) ı have a problem with firstValue = infos["rates"][firstCurrency] this line, why ? -
Conditional Django form validation
For a Django project, I have a customized User model: class User(AbstractUser): username = None email = models.EmailField(_('e-mail address'), unique=True) first_name = models.CharField(_('first name'), max_length=150, blank=False) last_name = models.CharField(_('last name'), max_length=150, blank=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['first_name', 'last_name'] objects = UserManager() def __str__(self): return self.email I'm creating a new user registration form: class UserRegistrationForm(forms.ModelForm): auto_password = forms.BooleanField(label=_('Generate password and send by mail'), required=False, initial=True) password = forms.CharField(label=_('Password'), widget=forms.PasswordInput) password2 = forms.CharField(label=_('Repeat password'), widget=forms.PasswordInput) class Meta: model = User fields = ('email', 'first_name', 'last_name', 'is_staff', 'is_superuser') def clean_password2(self): cd = self.cleaned_data if cd['password'] != cd['password2']: raise forms.ValidationError(_("Passwords don't match.")) return cd['password2'] My form has a auto_password boolean field. When this checkbox is set, the password and password2 fields must not be checked, as their content (or the absence of content) has no importance. On the opposite, when the auto_password checkbox is unset, the password and password2 must be checked. Is there a way to optionnally disable the Django form checks whenever needed? Thanks for the help. -
Django + Gunicorn + Gevent RecursionError
I'm running into a RecursionError with Django + Gunicorn + Gevent. My understanding is that my Gevent monkeyPatch is being called too late. Where should I call from gevent import monkey monkey.patch_all() If I'm running my django server with the following command? gunicorn --workers=4 --log-level=debug --timeout=90 --worker-class=gevent myapp.wsgi -
Django role permissions - available_permissions aren't automatically assigned to Group
I'm trying to use django-role-permissions but it doesn't assign available_permissions to Group nor to User. from rolepermissions.roles import AbstractUserRole class PERMISSIONS: CAN_SEE_ALL_INVOICES = 'can_see_all_invoices' CAN_SEE_OWN_INVOICES = 'can_see_own_invoices' class Admin(AbstractUserRole): verbose_name = 'Admin' available_permissions = { PERMISSIONS.CAN_SEE_ALL_INVOICES:True, } class Broker(AbstractUserRole): verbose_name = 'Maklér' available_permissions = { PERMISSIONS.CAN_SEE_ALL_INVOICES: False, PERMISSIONS.CAN_SEE_OWN_INVOICES: True, } After sync_roles I checked the admin and also tried to programmatically check the permission for the user that has Broker role and they doesn't have the permission. How is that possible? -
Flutter and Python - Smoothest way to combine as frontend and backend
for more complex applications written in Flutter, I would like to use Python as a backend. There is the pub.dev package starflut that looks promising but does not seem to have many applications. On the other hand, there seem to be attempts, to connect them via Python web - frameworks like flask (I) or flask (II) or Django. Since all of those options require some effort to be handled, I would like to know, what your choice and experiences with those attempts are. Best regards -
Why am I getting this error when I run my django project?
So I'm currently working on a Django project that has 2 models (Route and Address). The user can create a route using a route form and then add addresses that belong to the route they created using an address form. I have made a one-to-many relationship between the Route and Address models by adding the route's primary key as the address's foreign key. After successfully adding addresses that have a route_name as their foreign key, I want to print out on an HTML page all the addresses that have a common route_name so I did in by using a ListView in views.py that passes the route_name of addresses into the URL. and in urls.py I added a path that also has route_name of addresses as a parameter that is expected in the path. I have tried to do this in another part of my project where I view all the routes that were created by a user by passing the user's username and comparing it to Route's user and it worked. I will copy and paste all the pages for you to be able to see, I am having a problem with the RouteAddressListView that is in the bottom of … -
Error - (django-taggit) - 'post_list_by_tag' with arguments '('',)' not found
studying django, can't find a solution. added tags and the site gives an error studying django, can't find a solution. added tags and the site gives an error list.html <p class="tags"> Tags: {% for tag in post.tags.all %} <a href="{% url 'blog:post_list_by_tag' tag.slug %}"> {{ tag.name }} </a> {% if not forloop.last %}, {% endif %} {% endfor %} </p> ``` urls.py from django.urls import path from . import views app_name = 'blog' urlpatterns = [ # post views path('', views.post_list, name='post_list'), # path('', views.PostListView.as_view(), name='post_list'), path('<int:year>/<int:month>/<int:day>/<slug:post>/',views.post_detail,name='post_detail'), path('<int:post_id>/share/', views.post_share, name='post_share'), path('tag/<slug:tag_slug>/', views.post_list, name='post_list_by_tag'), ] -
Django how do i filter the difference between two filtered objects?
How do i get the difference between feedback and feedback2 ? here is my views.py. feedback = TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords.objects.filter( fmCustomerID__company_name__in=company.values_list('fmCustomerID__company_name')).filter( fmCustomerEmployeeSupplierID__in=employee.values_list('id')).filter(id=id) feedback2 = TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords.objects.filter( fmCustomerID__company_name__in=company.values_list('fmCustomerID__company_name')).filter( fmCustomerEmployeeSupplierID__in=employee.values_list('id')) nosubmit = TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords.objects.\ filter(Q(dateSubmitted__in = feedback.values_list('dateSubmitted')) & Q(dateSubmitted__in = feedback2.values_list('dateSubmitted'))) -
Problem with ajax, does not show error block
Problem with ajax. I get json with views.py and how can I split it into success and error blocks? Right now there is always only one success block in my js file and I have to start the error block somehow. file views.py: def advert(request): if request.method == "POST": form = TestForm(request.POST) if(form.is_valid()): message={ 'status' : True, 'message': request.POST['number'], } else: message={ 'status' : False, 'message': "Error", } return JsonResponse(message) return render(request,'market/new_date.html',{'form':TestForm(request.POST)}) file valid.js: $('#form').submit(function() { // catch the form's submit event $.ajax({ // create an AJAX call... data: $(this).serialize(), // get the form data type: $(this).attr('method'), // GET or POST url: $(this).attr('action'), // the file to call success: function(data) { // on success.. console.log(data.message) }, error: function(data) { console.log('error') } }); return false; }); -
Django/Nginx - Static files not found
I'm trying to deploy a very simple Django app that uses VueJS with Webpack-Loader using Django-Webpack-Loader. I can run my app in local without any problem using manage.py runserver and npm run serve. Now i'm trying to deploy this simple app to DigitalOcean using Gunicorn and Nginx. The problem is that while i can see the standard templates being rendered by django, my Vue files are not loading and i only get a lot of errors, it loooks like the static folders are not being retrievede although i have a static directory: GET http://URL/static/vue/js/chunk-vendors.js net::ERR_ABORTED 404 (Not Found) GET http://URL/static/vue/js/index.js net::ERR_ABORTED 404 (Not Found) The full code of the application is HERE, it's not mine, i'm just running a simple example to get started. My static directory is located on django_vue_mpa>static Can anyone help me on this? I made sure to build my frontend for production using npm run build and i collected my static files using manage.py collectstatic, but i still get the error. Any kind of advice is appreciated. -
Django Reverse for 'setrefresh' not found. 'setrefresh' is not a valid view function or pattern name
I have a web page and on this webpage I have a button. I am trying to get it so that when the user clicks this button it will call an API endpoints and update the database model I have created. Please let me know if you need more info, I'm completely lost at the moment. sets.html {% block content %} <div class="background card"> <div class="card-body"> <button class="btn" id="setRefresh" style="border: 1px solid #555555; color: #555555" onclick="location.href={% url 'setrefresh' %}"><i class="fas fa-sync"></i></button> </div> </div> {% endblock%} views.py def sets(request): return render(request, "main/sets.html", {"Sets": Set.objects.all}) def setrefresh(request): try: response = requests.request("GET", "https://api.scryfall.com/sets") data = response.json() data = data["data"] for entry in data: s = Set() s.scry_id = entry["id"] s.code = entry["code"] s.name = entry["name"] s.set_type = entry["set_type"] s.release_date = entry["released_at"] s.card_count = entry["card_count"] s.digital_only = entry["digital"] s.foil_only = entry["foil_only"] s.nonfoil_only = entry["nonfoil_only"] s.icon = entry["icon_svg_uri"] s.status = 0 s.save() return HttpResponse("ok") except Exception: return HttpResponseBadRequest() urls.py urlpatterns = [ path('', views.dashboard, name="dashboard"), path('sets', views.sets, name="sets"), path('cards', views.cards, name="cards"), url(r'^setrefresh/', views.setrefresh, name='setrefresh'), ] -
Bootstrap Modal popup and Django
I'm new to django/bootstrap and currently i'm practising by using an html/css/js template which i downloaded from the internet. I rendered the template with django successfully by following a tutorial. Now i want to configure Login/Register to learn Django authentication. Now when i press Login/Register button (picture1) a popup is displayed. I tried to render loginregister page. <li class="list-inline-item list_s"><a href="{% url 'loginregister' %}" class="btn flaticon-user" data-toggle="modal" data-target=".bd-example-modal-lg"> <span class="dn-lg">Login/Register</span> I've created a views.py file, configured the urls.py file and created an html file in order to display my page and not the popup but unsuccessfully the popup is always displayed. I've configured the following: index.html file <!-- Responsive Menu Structure--> <!--Note: declare the Menu style in the data-menu-style="horizontal" (options: horizontal, vertical, accordion) --> <ul id="respMenu" class="ace-responsive-menu text-right" data-menu-style="horizontal"> <li> <a href="#"><span class="title">Manage Property</span></a> </li> <li> <a href="#"><span class="title">Blog</span></a> </li> <li class="last"> <a href="{% url 'contact' %}"><span class="title">Contact</span></a> </li> <li class="list-inline-item list_s"><a href="{% url 'loginregister' %}" class="btn flaticon-user" data-toggle="modal" data-target=".bd-example-modal-lg"> <span class="dn-lg">Login/Register</span></a></li> <li class="list-inline-item add_listing"><a href="#"><span class="flaticon-plus"></span><span class="dn-lg"> Create Listing</span></a></li> </ul> </nav> </div> </header> <!-- Main Header Nav Ends --> <!-- Login/Register Starts --> <!-- Modal --> <div class="sign_up_modal modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-lg" role="document"> <div … -
changing models.integerfield() using ajax
it doesn't work even when i put a number for testing in front of device.degree in views.py. its my input and submit button : <div class="col-log-7 px-5 pt-7"> <p>Rooms tempreture:</p> <input type="number" placeholder="degree"> <button type=submit text="submit degree" onclick=update_degree()> </div> ajax : function update_degree() { if (window.XMLHttpRequest) { // code for modern browsers xhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("POST", "degree", true); xhttp.send(); }; urls.py : path('degree',views.degree_views,name='degree'), views.py : @csrf_exempt def degree_views(request): device = Device.objects.get(id=1) device.degree = 10 device.save() return HttpResponse() can anyone tell me what should i do ? -
Django migrate showing Operations to perform instead of performing migration in Django v3.1
I had started to upgrade an old web application from django v2.7 to django v3.1 for my academic purpose. manage.py migrate. Then it showed some successful migration. Then I created a super user by manage.py createsuperuser and tried to login to admin. But after entering the successful credential, it showed an 500 server error. I found that admin migration not yet performed. Then I tried manage.py migrate admin,Then the output like this Operations to perform: Apply all migrations: admin Running migrations: No migrations to apply. I tried many result mentioned in different blogs and forums, but did not work. So I am wondering whether it is applicable to django v3.1. Could anyone help me.