Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Graphene-Django and CORS issue related to GraphQLerror: "message": "GraphQL only supports GET and POST requests."
I am having serious trouble with this issue. Scouring the internet has yielded me with many StackOverflow and Github threads on the matter but none of them fix the problem at hand. I am creating a GraphQL endpoint for a backend through graphene-django and am encountering CORS pre-flight request issues when connecting to it. I know that the CORS works in all the other contexts, e.g. for using the /admin/ url, however when hitting the /graphql/ url, it fails. I found, through the use of Insomnia (a type of Postman) that it fails because the OPTIONS pre-flight request is rejected by GraphQLView in the following lines of the graphene-django source code: if request.method.lower() not in ("get", "post"): raise HttpError( HttpResponseNotAllowed( ["GET", "POST"], "GraphQL only supports GET and POST requests." ) ) as may be found here https://github.com/graphql-python/graphene-django/blob/main/graphene_django/views.py. I know that the headers are provided correctly back as Insomnia notifies me that they are connected to this 405 Method Not Allowed OPTIONS call. Supposedly, installing django-cors-headers fixes this problem for everyone else but it does not seem so for me: https://github.com/graphql-python/graphene-django/issues/778 https://github.com/graphql-python/graphene-django/issues/288 How to solve error 405 method not allowed, for django graphql server and react axios in front end My … -
Overwrite Django permission
I want to make the permissions in views instead of the default at models I create a main class called CreatorView from django.views.generic import View from django.forms.models import modelform_factory class CreatorView(View): model = None fields = None exclude = None form = None page_title = '' def create_form(self): default =dict() if self.fields == None: if self.exclude == None: default['fields'] = self.fields = self.model._meta.fileds else: default['exclude'] = self.exclude else: if self.exclude: raise Exception('error') default['fields'] = self.fields return modelform_factory(self.model,**default) def get(self,request,*args,**kwargs): return render('','base.html') def post(self,request,*args,**kwargs): ... and so on the main urls is: urlpatterns = [ path('%s/%s' % (cls.model._meta.app_label, cls.__name__.lower()), cls.as_view(), name='%s/%s' % (cls.model._meta.app_label, cls.__name__.lower())) for cls in CreatorView.__subclasses__()] if I make inheritance from CreatorView then my class should create a page for example: class Login(CreatorView): model = Users """ my overwrite methods and actions """ class Configurations(CreatorView): model = Configure """ my overwrite methods and actions """ class Teachers(CreatorView): model = Teachers """ my overwrite methods and actions """ class Students(CreatorView): model = Students """ my overwrite methods and actions """ and so on this code will create to me four pages I want to create table semi to django content_type model to be like: id app_label page 1 myapp login … -
Django-App deployed in network with Gunicorn /NGINX - not accessible on private IP
I deployed a DjangoApp following this documentation: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-debian-10 The aim is to make the app available within a company network. It perfectly works except of the following problems: on localhost the default nginx page is displayed (even though I removed default from sites-available and sites-enabled) It is not accessible on the private IP (192.168....) even though the private IP is defined in settings.py (ALLOWEDHOSTS = …) and in the nginx configuration file: “server { listen 80; servername private_IP; }” The app is available locally on 127.0.0.1 I don’t get any error messages What could be wrong with my configuration? What could I test? -
Django Calculated fields do not appear in get_fields()
I have a calculated field in a model. class SfShifts(models.Model): pr_id = models.PositiveIntegerField(primary_key=True, db_column='pr_id__c') def _get_calculated_field(self): return {'cal': self.pr_id} calculated_field = property(_get_calculated_field) But when I call get_fields() I don't get it. field_list = [field.get_attname_column() for field in self.model._meta.get_fields()] How can I get the calculated field name too? -
Django admin: inherit base class field such that it is used to set the model's field on save
Say I have models A, B, C, each have a foreign key field foo to model Foo. foo is a difficult field to select, hence we rather use a field bar (a foreign key to model Bar), and depending on the entry selected, our code selects the correct Foo. The bar field is not part of A, B, or C, only foo is. Now in django admin models for A, B, and C, I am trying to make a common base model they can inherit from which will handle this functionality. # --- models.py class BaseModel(models.Model): foo = models.ForeignKey(Foo, on_delete=models.PROTECT) class A(BaseModel): name = models.CharField("A name", max_length=200, unique=True) class B(BaseModel): enabled = models.BooleanField("Be enabled", default=True, ) class C(BaseModel): count = SmallFloatField("Count of things", ) # --- admin.py class BaseAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): form = super().get_form(request, obj, **kwargs) # This form object does not have .fields attribute form.fields = [x for x in form.fields if x != 'foo'] form.fields += 'bar' return form @admin.register(A) class AAdmin(BaseAdmin): pass @admin.register(B) class BAdmin(BaseAdmin): pass @admin.register(C) class CAdmin(BaseAdmin): pass Unfortunately form.fields does not exist on the form object. How does one replace a field of a base ModelAdmin class such that its derived … -
How to format django-filters with crispy forms?
Is it possible to format a django_filters filter form with django-crispy-forms? I've been trying to do that, but django_filters.FilterSet doesn't seem to accept the crispy forms formats (from DeviceFilter class). It doesn't give an error either.The only thing that seems to be able to give a format is {{ filter.form|crispy }} but I want to be able to do it in python with FormHelper(). filters.py from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Submit, Row, Column import django_filters class DeviceFilter(django_filters.FilterSet): device_type = django_filters.ModelChoiceFilter(lookup_expr='exact', field_name='device_type__pk', queryset=None) device_group = django_filters.ModelChoiceFilter(lookup_expr='exact, field_name='device_group__pk', queryset=None) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.filters['device_type'].queryset = DeviceType.objects.filter(owner=self.request.user) self.filters['device_group'].queryset = DeviceGroup.objects.filter(owner=self.request.user) self.helper = FormHelper() self.helper.layout = Layout( Row( Column('device_type', css_class='form-group col-md-6 mb-0'), Column('device_group', css_class='form-group col-md-4 mb-0'), css_class='form-row' ), Submit('submit', 'filter') ) class Meta: model = Device fields = {} template <!-- filter --> {% if filter %} <form method="get"> {{ filter.form|crispy }} </form> {% endif %} -
Django models in admin return TypeError: bad operand type for unary -: 'str'
I'm working on a project using Django(3) and Python(3) in which I have added few models and added those models in admin.py, but when I open the admin panel and try to add an object for those models it returns an error. Here's one of my model which is returning error: From models.py: class CurrencyManagementAssetsModel(models.Model): RequestId = models.IntegerField(blank=False) CbnInstitutionCode = models.CharField(max_length=5, blank=False) SortCode = models.CharField(max_length=10, blank=False) Count = models.IntegerField(blank=False) AssetClassificationId = models.IntegerField(blank=False) AssetTypeId = models.IntegerField(blank=False) ValueOfCurrencyDistributed = models.DecimalField(max_digits='20', decimal_places='10', blank=False) VaultCapacity = models.DecimalField(max_digits='20', decimal_places='10', blank=False) Year = models.IntegerField(blank=False) HalfOftheYear = models.IntegerField(blank=False) class Meta: verbose_name = 'Currency Management Assets' and Here's the error I'm getting when click on that particular model in admin: Request Method: GET Request URL: http://127.0.0.1:8000/admin/reports/currencymanagementassetsmodel/ Django Version: 3.1.3 Exception Type: TypeError Exception Value: bad operand type for unary -: 'str' What can be wrong here? -
Bypassing the unique constraint when defining a foreign key to just one field in Django
I've a model as shown below: class Instance(models.Model): data_version = models.IntegerField(default=1, unique=True) name = models.CharField(max_length=200) The data_version field has to be related to all other models in the application: class Source(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=200) version = models.ForeignKey(Instance, on_delete=models.CASCADE, to_field='data_version', null=True) The problem here is that Django requires the field data_version to be a unique field for me to be able to define such a relationship but that simply doesn't fit into my use case. I need to have multiple Instance objects in the app, each with version numbers starting from 1. What I'd like is to have a unique constraint on the combination of name and data_version but then Django doesn't allow defining Foreign key relationships as shown above. Is there a way I can bypass this restriction? -
Combining answer and question fields (django)
I have a question answer quiz. I have 2 models Question and Answer. I want to have 2 pages. On the first page there will be a Question model where the user will write the question and the answer to that question. On the second page I will display these questions and accordingly the Answer model where the customer enters the answer and then check if it is equal to the ** answer_question ** of the Question. But I could not do that so call each question Answer and show it in html. this is my code --> models.py --> from django.db import models # Create your models here. class Question(models.Model): question=models.CharField(max_length=100) answer_question=models.CharField(max_length=100, default=None) def __str__(self): return self.question class Answer(models.Model): questin=models.ForeignKey(Question, on_delete=models.CASCADE) answer=models.CharField(max_length=100,blank=True) def _unicode__(self): return unicode(self.questin) views.py --> from django.shortcuts import render from django.shortcuts import render, HttpResponse from django.http import HttpResponseRedirect from django.shortcuts import redirect from .forms import QuestionForm,AnswerForm from .models import Question def home(request): form=QuestionForm if request.method=='POST': form=QuestionForm(request.POST) if form.is_valid(): form.save() return render(request, "question/base.html", {"form":form}) def ans(request): form=AnswerForm e=Question.objects.all() if request.method=="POST": form=AnswerForm(request.POST) if form.is_valid(): form.save() return render(request, "question/ans.html", {"form":form, "e":e}) forms.py --> from django import forms from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.forms import ModelForm … -
In Django the CustomUserForm is not adding users to the database (i.e. to the `User` model)
I have created a CustomForm by inheriting the UserCreationForm for user registration as follows (code reference): class CustomForm(UserCreationForm): email = forms.EmailField(required=True) firstname = forms.CharField(required=True) lastname = forms.CharField(required=False) class Meta: model = User fields = ("username", "firstname", "lastname", "email") def save(self, commit=True): user = super(CustomForm, self).save(commit=False) user.first_name = self.cleaned_data["firstname"] user.last_name = self.cleaned_data["lastname"] user.email = self.cleaned_data["email"] if User.objects.filter(email = user.email).exists(): raise ValidationError("Email exists") elif commit: user.save() return user I am facing the following issues: Although I have added a condition to make sure unique email is used, I am still able to register a user with the same email address without getting any errors. Though the CustomForm seems to work fine, but when I checked my User model through admin panel, no new users are being added there, and as a result, I am not able to log in. i.e. the CustomForm is not adding users to the database (User model) What can I do to solve the above two issues? -
Is it possible to combine a django app and a javascript app into one app?
I'm looking for ideas on how to implement the following requirement. I have 2 different applications one being a python Django app and the other one being a pure javascript app. I can get both the apps running on different ports but I need to be able to integrate the js app into the Django app. I.e. I want to add the js app into the Django app such that when you navigate to djangoapp.com/admin/js_app you go to the landing page of the js_app application. the 2 apps are https://github.com/CodeForAfrica/gmmp and https://github.com/OpenUpSA/wazimap-ng-ui any ideas will be appreciated -
Django template : sorting by value of __str__
I am using django 3 and I have surcharged the str function for my model : class SubSubCategory(models.Model): subCategory = models.ForeignKey(SubCategory, on_delete=models.CASCADE) name = models.CharField("Nom du sous sous category" , max_length=200, ) description = models.CharField("Description du sous sous category" , max_length=200, null=True, blank=True) def __str__(self): description_locale = self.name + " : " + self.description if self.description else self.name hierarchie = [str(x) for x in [self.subCategory.category, self.subCategory, description_locale]] description_totale = " > ".join(hierarchie) return description_totale How could I ask my template to order my list according to this str representation ? I would like to do something like : {% for SubSubcategory in object_list|dictsort:'str' %} but it obviously doesn't work, as "str" is nothing. How do I call the string representation of an object in a template ? to pass it as an ordering order ? -
How to display particular stuff of the registered person in profile page - Django
I have a member table, I want to fetch and display some of the fieldsets like fullname , email and phone number in the profile page. here is the views.py def index(request): if request.method == 'POST': member = Member( fullname=request.POST.get('fullname'), companyname=request.POST.get('companyname'),Email=request.POST.get('email'),password=request.POST.get('password'),contactno=request.POST.get('contactno'),role=request.POST.get('role'),) member.save() return redirect('/') else: return render(request, 'web/index.html') here is the models.py class Member(models.Model): fullname=models.CharField(max_length=30) companyname=models.CharField(max_length=30) Email=models.CharField(max_length=50) password=models.CharField(max_length=12) contactno = models.CharField(max_length=30,default='anything') -
Auto login in django webapp opened in an iframe inside microsoft dynamics
Situation: I have a developed a webapp using django which uses the default authentication middleware.All the views are login_required. Now client wants when he will login into CRM then webapp will open in an iframe and he should be auto logged inside django webapp as well. Issues: Opening webapp inside an iframe in CRM can be done. But how can django webapp create a session for the user logged in inside CRM? Django uses its own authentication, CRM uses its own. Even If i link Django authentication with azure active directory , still username and password has to be entered in the iframe.I cannot figure out how auto login will be done. Please suggest -
how to serialize a dictionnary using Composite fields
I am trying to develop a POST API. I am trying to use a dictionnary to store social links of an actor model socials links should be stored in a variable socials in the Actor model. socials= {"facebook":"www.facebook.com/" , "instagram":"www.instagram.com/" ,"linkedin":"www.linkedin.com/" } Here is the actor model model.py class Actor: name = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique=True) bio = models.TextField() created = models.DateTimeField(default=timezone.now ) updated = models.DateTimeField(auto_now=True) socials = models.CharField(max_length=1024 , blank=True) class Meta: app_label = 'actors' verbose_name = _('Actor') verbose_name_plural = _('Actors') ordering = ('name',) def __str__(self): return self.name serializer.py class ActorSerializer(serializers.ModelSerializer): added_by = serializers.ReadOnlyField(source='added_by.username') socials = serializers.DictField( child=serializers.URLField(max_length=200, min_length=None, allow_blank=False) ) class Meta: model = Actor fields = '__all__' views.py class ActorListView(generics.ListCreateAPIView): queryset = Actor.objects.all() serializer_class = ActorSerializer This is my code. But there is something missing in order to do what I want (I got an error). Could any one suggest a solution ? bold italic -
Django, Archery System
This is more a plea for guidance rather than any hard coding example. I have set myself a problem to write an archery recording system using Django. I have got the recording system working well and the system can register users, record their scores, show their scores filtered by round, show the users scores who have shot a particular round etc. This issue I have got is when it comes to classifying the score. I will explain: In archery scores are recorded against the round you shoot. These vary so you have 60+ rounds to choose from each having different criteria and different maximum scores. Archers are grouped according to gender and age (10 sub groups) The classification system works by taking the round shot and the sub-group that the archer falls into and looking across a table of values. The classification gained is the one that the score falls into i.e. if you are male and over 18 you are grouped as a 'Gentleman' The round you shoot is called a 'York' and you score 550 The table you would consult would look like this Round | 3rd Class | 2nd Class | 1st Class | Bowman | Master … -
creating notification using django
how to create a simple notification page using django. I have tried with many codes but none of the concept worked for my project. Suggest me a simple and accurate concept. whenever we click on the notification page notification like post created at a particular time should get displayed. I will be kindful if you could suggest the needful code. Thankyou in advance. -
MYSQL Django Login
login page def logins(request): if request.method == "POST": email = request.POST.get('email') password2 = request.POST.get('password2') print email print password2 ------------runfine --------- user = authenticate(email=email, password2=password2) if user is not None: login(request, user) messages.success(request, 'Welcome' + request.POST.get('username')) return redirect('index') else: messages.info(request, 'Invalid Credentials') return render(request, "login.html") setting I had connected it with MySQL DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'as', 'USER':'root', 'PASSWORD':'', 'HOST':'127.0.0.1', 'PORT':' 3306', 'OPTIONS':{ 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" } } } URLs page path("logins/", views.logins, name="logins"), HTML page <form action="/logins/" method="post">{% csrf_token %} <div class="content"> {% for message in messages %} <h3 style="color:red"> {{message}} </h3> {% endfor %} </div> <div class="field"> <input type="text" name="email" required> <label>Email ID</label> </div> <div class="field"> <input type="password" name="password2" required> <label>Password</label> </div> <div class="content"> <div class="checkbox"> <input type="checkbox" id="remember-me" > <label for="remember-me">Remember me</label> </div> <div class="pass-link"> <a href="#">Forgot password?</a></div> </div> <div class="field"> <input type="submit" value="Login"> </div> <div class="signup-link">Not a member? <a href="/signup">Signup now</a> </div> </form> it does not execute if statement in the login it always showing me the else Part and do not give any error and also created a database in my SQL name as and I had also migrated the files I store the data inside my MySQL using Django but I … -
Django project template doesn't exist
Hi i'm just getting started with Django and i'm running a project, I have created an HTML file and this is the views.py def index(request): return render(request, "hello/index.html") and this is the urls.py inside the maine file from django.contrib import admin from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), path('hello/', include("hello.urls")) ] and this is the urls.py inside the project file from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), ] and i got this error view from my project -
django list_filter is not scrollable
I have a long list of elements (50 elements) and I wanted to use that as a list_filter in django admin panel. But when I use this list, on very right side where FILTER panel appears I can see only 20 items and it is not scrollable so rest of 30 is hidden. How can I get those 30 items in FILTER section or How scrolling will be possible so that all 50 items can be viewed. -
FlatPicker in Django Edit custom form showing time, only days
I have a Django app, with new template where datetimepicker works well. I created an edit template but the widget do not load automatically, so I added them. But for some reason, i do not know how to bring the datetimepicker, I can only get the datepicker. Does anybody knows please ? The precise line in the edit template looks like: <div> <input id="Restriction_Start_Date_id" type="text" name="Restriction_Start_Date" value="{{ restricted_name_obj.Restriction_Start_Date|date:'n/j/Y G:i' }}" class="form form-control datepicker" > </div> While on the new template I have : <div>{{ form.Restriction_Start_Date.label_tag }}</div> <div> {{ form.Restriction_Start_Date.errors }} {{ form.Restriction_Start_Date }} </div> -
django auto decrement an IntegerField
models.py class Dispositivo(models.Model): fornitore= models.ForeignKey(Fornitore, on_delete=models.CASCADE) codiceProdotto = models.CharField(max_length=100, verbose_name="Codice prodotto") quantita = models.IntegerField(blank=True, default="1", verbose_name="quantità") class Fattura(models.Model): dispositivo = models.ManyToManyField(Dispositivo, related_name='fattura_disp', default='0', limit_choices_to={'quantita__gte' : 1}, ) fattura = models.FileField(blank=True, upload_to="fatture/%Y/%m/%d") creato = models.DateField(verbose_name="data vendita") def dispositivi(self): return "\n, ".join([p.codiceProdotto for p in self.dispositivo.all()]) admin.py @admin.register(Dispositivo) class DispositivoModelAdmin(admin.ModelAdmin): model = Dispositivo list_display = ['codiceProdotto', 'descrizione', 'quantita' , 'venduto', 'fornitore', 'DDT', 'creato'] list_editable = ['venduto', 'quantita'] def get_queryset(self, request): qs = super(DispositivoModelAdmin, self).get_queryset(request) return qs.filter(quantita__gte=1) @admin.register(Fattura) class FatturaModelAdmin(admin.ModelAdmin): model = Fattura list_display = ['cliente', 'dispositivi', 'fattura', 'creato'] in admin pannel when i create a Fattura i select more Dispositvi, which method i must override for auto decrement of Dispositivi ? -
Stripe CLI webhook not invoked when card declined
I am using the stripe CLI to test webhooks in my django application. When a payment goes through, the webhook records this and seems to work perfectly fine. However, whenever I am using one of the stripe test cards that get declined (such as: 4000000000009987), its as if the webhook never gets called, even though stripe tells me the error that the card was declined. It's as if the webhook never even gets called from stripe when a payment fails. What am I missing? my webhook in python @require_POST @csrf_exempt def webhook_received(request): stripe.api_key = settings.STRIPE_SECRET_KEY endpoint_secret = settings.STRIPE_ENDPOINT_SECRET payload = request.body sig_header = request.META['HTTP_STRIPE_SIGNATURE'] event = None try: event = stripe.Webhook.construct_event( payload, sig_header, endpoint_secret ) except ValueError as e: # Invalid payload return HttpResponse(status=400) except stripe.error.SignatureVerificationError as e: # Invalid signature return HttpResponse(status=400) print('THE EVENT: ', event) print('THE EVENT TYPE: ', event.type) # Handle the event if event.type == 'payment_intent.succeeded': payment_intent = event.data.object # contains a stripe.PaymentIntent # Then define and call a method to handle the successful payment intent. # handle_payment_intent_succeeded(payment_intent) elif event.type == 'payment_method.attached': payment_method = event.data.object # contains a stripe.PaymentMethod # Then define and call a method to handle the successful attachment of a PaymentMethod. # handle_payment_method_attached(payment_method) … -
django page not found when creating a register and sign up
I tries to fix this problem so many times but I get this error always and also I tired to make register page with django "404 page not found" any way this is some files in my code files in my code and also push this to git https://github.com/dtheekshanalinux/learnprogramming if don't mind go and check it out index.html in templates {% load static %} {% static "images" as baseUrl %} <!doctype html> <!-- Website Template by freewebsitetemplates.com --> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Mustache Enthusiast</title> <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/mobile.css' %}" media="screen and (max-width : 568px)"> <script type="text/javascript" src="{% static 'js/mobile.js' %}"></script> </head> <body> <div id="header"> <a href="{% static 'index.html' %}" class="logo"> <img src="{% static 'images/logo.jpg' %}" alt=""> </a> <ul id="navigation"> <li class="selected"> <a href="{% static 'index.html' %}">home</a> </li> <li> <a href="{% static 'about.html' %}">about</a> </li> <li> <a href="{% static 'accounts/register' %}">register</a> </li> <li> <a href="{% static 'contact.html' %}">contact</a> </li> </ul> </div> <div id="body"> <div id="featured"> <img src="{% static 'images/the-beacon.jpg' %}" alt=""> <div> <h2>the beacon to all mankind</h2> <span>Our website templates are created with</span> <span>inspiration, checked for quality and originality</span> <span>and meticulously sliced and coded.</span> <a href="{% static 'blog-single-post.html' … -
Installing nested Django app causes RuntimeError
So, basically, I have a project structure like that: project |__ admin_panel/ | |__ admins/ <- django application | |__ orderlist/ <-- another django application |__ project/ | |__ settings.pu <-- django settings module |__ manage.py And my INSTALLED_APPS config looks something like that: INSTALLED_APPS = [ ..., 'admin_panel.admins', 'admin_panel.orderlist', ] I want to use AppConfig class for my orderlist django application. It is not loaded by default: # admin_panel/orderlist/apps.py from django.apps import AppConfig class OrderlistConfig(AppConfig): name = 'orderlist' def ready(self): print('.ready() was called') from . import signals There is no .ready() was called message when starting Django test server I've tried to specify AppCofnig path directly on INSTALLED_APPS: INSTALLED_APPS = [ ..., 'admin_panel.admins', 'admin_panel.orderlist.apps.OrderlistConfig', ] But this causes error: Traceback (most recent call last): File ".../manage.py", line 22, in <module> main() File ".../manage.py", line 18, in main execute_from_command_line(sys.argv) File ".../lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File ".../lib/python3.9/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File ".../lib/python3.9/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File ".../lib/python3.9/site-packages/django/apps/registry.py", line 83, in populate raise RuntimeError("populate() isn't reentrant") RuntimeError: populate() isn't reentrant django/apps/registry.py code that fails: # An RLock prevents other threads from entering this section. The # compare and set operation below is atomic. if self.loading: # …