Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to allow UpdateView only to a user that owns that model - and that model is already connected with a foreign key
I want the Topping model to only be accessible to a current user, and not to other users who could access that page by copying the URL. models.py class Pizza(models.Model): name = models.CharField(max_length=20) owner = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.name def get_absolute_url(self): return "/pizzas" class Topping(models.Model): pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE) name = models.CharField(max_length=20) def __str__(self): return self.name def get_absolute_url(self): return reverse("pizza", kwargs={"pizza_id": self.pizza.pk}) views.py class UpdateTopping(LoginRequiredMixin, UpdateView): model = Topping form_class = UpdateToppingForm template_name = "pizzas/update_topping.html" Something along these lines (this has worked on the primary model): class UpdatePizza(LoginRequiredMixin, UpdateView): model = Pizza form_class = UpdatePizzaForm template_name = "pizzas/update_pizza.html" def get_queryset(self): base_qs = super(UpdatePizza, self).get_queryset() return base_qs.filter(owner=self.request.user) -
How to invoke a function when superadmin changes attributes from admin panel?
I wanted to send a notification to the user (or invoke any function in that case) if the attribute of the object is changed (For eg, an attribute ‘is_checked’ is changed to True) from the admin panel. Upon digging through the Django source code, I found the log entry class that is used in the admin panel. def check_state_change(): logs = models.LogEntry.objects.all() for log in logs: if log.action_flag == 2: if log.change_message == “[‘is_checked’]”: function(*object whose attribute was changed*) for now I am checking all the logs The above function does the job but I am unsure about the ways to invoke this function. Do I call it every 5mins or what are the better ways? -
Comment on multiple post objects on a single page using jQuery ajax in Django
I've been trying to implement a comment function with jQuery ajax in Django to allow me comment on multiple post object on a single page, but somehow I have a challenge figuring why I am getting the same comment repeated in other other post object comments, when commenting on a first post i sent the comment to the database without any issues but when I try comment on a second post on the same page it repeats the first comment for the second post on the same page, even thought the comment doesn't relate to that post object. To be clear why is ajax repeating my comment for other post object and if I refresh the post and try comment on another post object it send an empty post to the database how do I resolve this situation as when I comment on the first object it works fine but the when I try with the second post object it just repeat the first comment for the second post object. My view for comment def feedComment(request): if request.method == 'GET': post_id = request.GET['id'] comment = request.GET['comment_text'] post_obj = Post.objects.get(id=post_id) create_comment = Comment.objects.create(post=post_obj, username=request.user, comment=comment) create_comment.save() return JsonResponse({'comment':create_comment.comment,}) my ajax function … -
Is there any way to show the records in view mode when clicking the edit when it has fully billed status in Netsuite Suitescript 2.0
function beforeLoad(context){ var Type = context.type;if(Type== context.UserEventType.EDIT && Status=='fullyBilled'){ var form = context.form; return redirectUrl = url.resolveRecord({ recordType: 'purchaseorder', isEditMode: false }); } } -
How to make funtion call in Django views.py to render same template but with different queries?
class CartView(View): def get(self,request,pk): if request.user.is_authenticated: if Smart_phone.objects.filter(name=pk): product = Smart_phone.objects.filter(name=pk) items = product for item in items: if item.instock>0 : context ={'product':product} return render(request,'customer_purchase/cart.html',context) else: return render(request,'customer_purchase/home') elif Tabs.objects.filter(name=pk): product = Tabs.objects.filter(name=pk) items = product for item in items: if item.instock>0 : context ={'product':product} return render(request,'customer_purchase/cart.html',context) else: return render(request,'customer_purchase/home.html') elif Smart_watch.objects.filter(name=pk): product = Smart_watch.objects.filter(name=pk) items = product for item in items: if item.instock>0 : context ={'product':product} return render(request,'customer_purchase/cart.html',context) else: return render(request,'customer_purchase/home') else: return redirect('login') Here the loop is common for every query . Hence i want to call a function ,that does the rendering process . 'instock' is a field common to the models thats i am using here -
Running my Django site on pythonanywhere on my local machine
I've set up a basic Django server on Pythonanywhere, then I downloaded all of those files on my local machine. (the linking between the python-anywhere cloud server and my local machine is done via Git using pull & push commands) If I were to run on my computer, how should I approach this? Do I download django from pip and turn on virtual environment and run it there? I am just a bit confused. Since I don't know a whole lot about what's going and what webserver I am using on Pythonanywhere, I don't exactly how to run it on my local machine. I also saw in Pythonanywhere's docs not to run the runserver command. Is it even okay running it on my local machine? It won't change anything in the file themselves, right? -
How to auto-populate field in Django admin based on another fields value
I want to make a dependent auto-populate field which get populated with custom values when another field is selected by the user. I have searched but was not able to find the correct help. My case I want when the fertiliser name is selected the above field "phosphate" etc. should get populated based on the fertiliser name selected. -
Why does my django app keep givin me "getattr(): attribute name must be string" error?
How do I get default image as argument in creating a profile? My django keeps getting me error highlighting me getting User and me trying to use image. this is part of views.py in question user = User.objects.create_user(request.POST['username'], email=request.POST['email'], password=request.POST['password1']) user.is_active = False user.save() url = static('default-pfp.jpg') profile = Profile.objects.create(owner=user, profilePicture=url) This is lines I get highlighted in error TypeError at /profile/signup/ getattr(): attribute name must be string 1. profile = Profile.objects.create(owner=user, profilePicture=url) 2. user = User.objects.get(username=request.POST['username']) My static picture is located in static/blog/default-pfp.jpg. I also tried adding blog/ in my url. Im also using a docker and nginx here -
Does Django not support Jinja manual whitespace control?
I am trying to use the Jinja manual whitespace control inside a Django template {% if condition -%} {{ my_variable }} {% endif %} and get TemplateSyntaxError Could not parse the remainder: '-' from '-' Django version is 3.2, Jinja 3.1. Is this not supported? I see there is django-whiteless that might address this issue. -
Django - Not passing id from template to views
In my ToDoApp, I couldn't send the ID to my function. Not sure what mistake I'm making. Seems my function is correct because when I tested the form action with "datechange/1". It worked. Here is my code: Index.html {% extends 'base.html' %} {% block content %} <h3 style = "margin-bottom: 20px"><strong>To Do List App</strong></h3> <form method="POST" action="datechange/{{task.id}}"> {%csrf_token%} <ul class="list-group"> {% for task in tasklist %} <li class="list-group-item d-flex justify-content-between align-items-center"> <input type='hidden' name = {{task.id}}>{{task.tasks}} <span class="badge bg-primary rounded-pill">{{task.duedate}} <input type="date" name="datepick"/> <input type='submit' value = 'Update'> </span> </li> {% endfor %} </form> Views.py def index(request): tasklist = Task.objects.all() return render(request, 'index.html', {'tasklist':tasklist}) def datechange(request,id): # taskid = request.POST.get(id='task.id') # task = Task.objects.get(id=taskid) task = Task.objects.get(id=id) datepick = request.POST.get('datepick') task.duedate = datepick task.save() return HttpResponseRedirect(reverse('index')) Urls.py from django.contrib import admin from django.urls import path from . import views urlpatterns = [ path('admin/', admin.site.urls), path('',views.index,name='index'), path('datechange/<int:id>',views.datechange,name='datechange'), ] -
bootstrap filter-control doesn't work with server-side pagination
I've been trying to make the bootstrap filter-control select work with server-side pagination, however, selecting an option from the dropdown merely returns the initial table and not the table that contains the column with the data that I've selected. I know that the server-side pagination is causing this because if I use client-side pagination the filter-control works as intended. I also tried using data-disable-control-when-search as documentation states to use this whenever the filter-control is used alongside server-side pagination, but the problem persists. <table class="table table-borderless table-hover" data-side-pagination="server" data-disable-control-when-search="true" data-toggle="table" data-search="true" data-filter-control="true" data-click-to-select="true" data-pagination="true" data-pagination-loop="false" data-page-size="10" data-show-refresh="true" data-icons-prefix="fa" data-icons="icons" data-buttons-class="yellow" data-mobile-responsive="true" data-loading-font-size="14px" data-url="{% url "app:api/negotiations/all" %}"> <thead> <tr> <th data-field="request.short_code" data-searchable="false">{% translate "Request ID" %}</th> <th data-field="offer.short_code" data-searchable="false">{% translate "Offer ID" %}</th> <th data-field="request.sender.full_name" data-searchable="false">{% translate "Sender Name" %}</th> <th data-field="offer.traveller.full_name" data-searchable="false">{% translate "Traveller Name" %}</th> <th data-field="request.origin" data-searchable="true" data-filter-control="select">{% translate "Origin" %}</th> <th data-field="request.destination" data-searchable="true" data-filter-control="select">{% translate "Destination" %}</th> <th data-field="status" data-formatter="statusFormatter" data-searchable="false">{% translate "Status" %}</th> <th data-field="offer.departure_date" data-searchable="true" data-filter-control="select">{% translate "Date of Departure" %}</th> <th data-field="offer.arrival_date" data-searchable="true" data-filter-control="select">{% translate "Date of Arrival" %}</th> <th data-field="is_reported" data-searchable="false" data-formatter="reportedFormatter" data-align="center">{% translate "Reported" %}</th> <th data-field="update_url" data-searchable="false" data-formatter="actionFormatter" data-align="center">{% translate "Action" %}</th> </tr> </thead> </table> -
Django Entity Relationship Diagram models problem
so i am learning django & have a diagram to write models using it. here is the diagram picture but the site gives me error when i submit my answer(models). the Bold fields are ForeinKey or PrimaryKey. i dont have to write the dim colored fields. and the italic ones should be inherited. this is my code: charities/models.py : from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): is_active = models.BooleanField(AbstractUser, default=True) is_staff = models.BooleanField(AbstractUser, default=False) is_superuser = models.BooleanField(AbstractUser, default=False) and accounts/models.py : from django.db import models from ..accounts.models import User class Benefactor(models.Model): EXP_CHOICES = ( ('0', 'Beginner'), ('1', 'average'), ('2', 'expert') ) user = models.OneToOneField(User, on_delete=models.CASCADE) experience = models.SmallIntegerField(null=True, blank=True, choices=EXP_CHOICES, default='0') free_time_per_week = models.PositiveSmallIntegerField(null=True, blank=True, default=0) class Charity(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=50, null=True, blank=True) reg_number = models.CharField(max_length=10, null=True, blank=True) class Task(models.Model): STATE_CHOICES = ( ('P', 'Pending'), ('W', 'Waiting'), ('A', 'Assigned'), ('D', 'Done'), ) assigned_benefactor = models.ForeignKey(Benefactor, null=True, on_delete=models.SET_NULL) charity = models.ForeignKey(Charity, on_delete=models.CASCADE) state = models.CharField(max_length=1, choices=STATE_CHOICES, default='P') title = models.CharField(max_length=60) what is the problem of my code guys? trying to solve it around 4 days and havent got anywhere. help me please. thanks. -
Connect/Authenticate Django Web App on SQL server using Key Vault, Azure AD or other (not using user-pass on my code)
I have Django web app, with an SQL server db, deployed on my Azure subscription. I need to connect/authenticate my Web App to SQL server (still on my Azure subscription) but I can't using username-password on my code. How can I do it? By key vault? By Azure AD? Thanks! -
static file not upleaded
I am using React inside Django app and facing issue of not loading static file my settings.py is from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-00cag42gtk)0_9#kn_8c3d1y-u!et#kqpa3@(i^bo@j@z#1jn9' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'leads.apps.LeadsConfig', 'rest_framework', 'frontend' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'leadmanager.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'leadmanager.wsgi.application' # Database # https://docs.djangoproject.com/en/4.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/ STATIC_URL … -
Forbidden (CSRF cookie not set.): /login/ REACT & DJANGO
I have built the frontend with react and backend with django and everything works fine on localhost but when I deployed the frontend on heroku and made a POST request to login (backend running on localhost still)I got the following error: Forbidden (CSRF cookie not set.): /login/ Front end code: https://pastebin.com/CHArh4JL function getCsrf(){ fetch("http://localhost:8000/csrf/", { credentials: "include", }) .then((res) => { let csrfToken = res.headers.get("X-CSRFToken"); setCsrf({csrf: csrfToken}); }) .catch((err) => { console.log(err); }) } const login = (event) => { event.preventDefault(); setIsLoading(true) fetch("http://localhost:8000/login/", { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": csrf.csrf, }, credentials: "include", body: JSON.stringify({username: username, password: password}), }) .then(isResponseOk) .then((data) => { console.log(data); setIsAuthenticated(true) localStorage.setItem("authenticated", true); setUsername('') setPassword('') setIsLoading(false) // this.setState({isAuthenticated: true, username: "", password: ""}); }) .catch((err) => { console.log('inside login catch') console.log(csrf.csrf, 'catch') console.log(err); }); } const isResponseOk = (response) =>{ if (response.status >= 200 && response.status <= 299) { return response.json(); } else { console.log(response) throw Error(response.statusText); } } useEffect(() => { //getSessions setIsLoading(true) fetch("http://localhost:8000/session/", { credentials: "include", }) .then((res) => res.json()) .then((data) => { // console.log(data); if (data.isAuthenticated) { setIsAuthenticated(true) console.log(data) } else { // test() setIsAuthenticated(false) console.log(data) getCsrf() } setIsLoading(false) }) .catch((err) => { console.log(err); }); }, []) backend code: https://pastebin.com/sXv1AWhK @require_POST … -
How to use an external project in my current project in VS code?
I have a python project in VS code and I run it locally. I want to link and connect my project to another project (the second project is cloned from git hub). I mean I want to have a link in the output of my first project (web application) which is linked to the second project. I cloned second project in the folder of the first project. I want to have the output of two projects together. I am confused now, and I don't know what should I do or from which file I should start to link them. -
Convert a string of list of ordereddict to a list with dictionaries
I have a dataframe in which every row contains a string like the following: "[OrderedDict([('id', 946), ('product', 'CRT6423'), ('quantity', 1)]), OrderedDict([('id', 947), ('product', 'CIN1199B'), ('quantity', 1)]), OrderedDict([('id', 948), ('product', 'CSS001'), ('quantity', 2)])]" This is in string format. I want to convert this into a list of dictionaries for which I am using literal_eval but it gives me the following error": ValueError: malformed node or string: <_ast.Call object at 0x00000175D77D9DF0> Expected output: [{"product":"CRT6423", "quantity":1}, {"product":"CIN1199B", "quantity":1}, {"product":"CSS001", "quantity":2}] -
unable to display image using jinja
I created a separate model for users to upload a profile pic. models.py class Image(models.Model): profilepic = models.ImageField(upload_to='images/', null = True) def __str__(self): return self.title html <img src="/images/{{ image.profilepic }}"/> all I am getting back is a empty canvas with an image icon I should note the images are uploading to the folder just not displaying -
Windows Django: Error: You don't have permission to access that port
I am trying to run a Django project in Windows but I am getting Error: You don't have permission to access that port. Running python manage.py runserver and python manage.py runserver "IP":"PORT" returned same result/error. I searched for answers but most or all of them are for Linux. -
how to handle this error when user search but didn't pass anything and found this kind of error in Django but user input id it work
views.py def paitent(request): search_query = '' if request.GET.get('search_query'): search_query = request.GET.get('search_query') if search_query == ' ': print('Ex') else: userprofile = Profile.objects.filter(id=search_query) profiles = Totallcount.objects.filter(image_owner=search_query) context = { 'profiles':profiles, 'userprofile':userprofile, } return render(request, "medical_report/paitent.html",context) paitent.html <form class="d-flex ms-auto my-3 my-lg-0" id='searchForm' action="{% url 'paitent' %}" method="get"> <div class="input-group"> <input class="form-control" type="search" placeholder="Search by Name" aria-label="Search" id="formInput#search" type="text" name="search_query" value="" /> <button class="btn btn-primary" type="submit" value="Search"> <i class="bi bi-search"></i> </button> </div> </form> Error. UnboundLocalError at /paitent/ local variable 'profiles' referenced before assignment Request Method: GET Request URL: http://127.0.0.1:8000/paitent/?search_query= Django Version: 3.2.15 Exception Type: UnboundLocalError Exception Value: local variable 'profiles' referenced before assignment Exception Location: C:\Users\21100002\Desktop\myreports\medical_report\views.py, line 176, in paitent Python Executable: C:\Users\21100002\Desktop\ocr\env\Scripts\python.exe Python Version: 3.7.0 -
How can i implement multi websites in one core in django?
How can I implement multi websites with one core in Django? I have multi websites with this structure: example.com (Main website) example.com/subdirectory1 (Second website) example.com/subdirectory2 (Third website) example.com/subdirectory2/en (Fourth website) example.com/subdirectory3 (Fifth website) I want to use one core to manage all websites. -
Django: Show data from current user
I'm having trouble displaying data from current user. It shows all the shifts that was given to other users also. I don't have any idea how to do this. Below is my code. models.py class User(models.Model): user_name = models.CharField(max_length=32, unique=True) pass_word = models.CharField(max_length=150) is_active = models.BooleanField(default=True) class Rostering(models.Model): name = models.CharField(max_length=64) begin_time = models.TimeField(default="") end_time = models.TimeField(default="") is_active = models.BooleanField(default=True) class RosteringUser(models.Model): rostering_user = models.ForeignKey(Rostering, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE) views.py def my_shift(request): if request.method == 'GET': queryset = RosteringUser.objects.all() if queryset: for obj in queryset: id = Rostering.objects.get(rosteringuser=obj.id) obj.id = id return render(request, 'my_shift.html', {'queryset': queryset}) my_shift.html {% for obj in queryset %} <tr> <td>{{ obj.user.user_name }}</td> <td>{{ obj.id.name }}-{{ obj.id.begin_time }}</td> <td>{{ obj.id.name }}-{{ obj.id.end_time }}</td> </tr> {% endfor %} Thank you in advance! -
Django admin filter_horizontal-like view without ManyToMany field
I need to assign many string values to one field in a model, and it should be possible with a tables like in filter_horizontal and ManyToMany field. Is there any way to do it without saving those strings in model?enter image description here -
Installed package was successful outside virtual env but errors inside virtual env
I have a package "fretboardgtr" successfully installed outside virtual env using pip. The modules work without any errors. I started a django project inside a virtual env and tried to install the same package inside the virtual env but it errors with the following error: Collecting fretboardgtr Using cached fretboardgtr-0.0.4-py3-none-any.whl (32 kB) Processing /Users/sajwaltamrakar/Library/Caches/pip/wheels/83/85/db/f83adc7591329e230cb5bda2a339e66a8dbd0f69ade492db56/svglib-1.4.1-py3-none-any.whl Collecting Pillow>=7.1.2 Using cached Pillow-9.2.0.tar.gz (50.0 MB) Collecting webencodings>=0.5.1 Using cached webencodings-0.5.1-py2.py3-none-any.whl (11 kB) Collecting svgwrite>=1.4 Using cached svgwrite-1.4.3-py3-none-any.whl (67 kB) Collecting cssselect2>=0.3.0 Using cached cssselect2-0.7.0-py3-none-any.whl (15 kB) Collecting lxml>=4.5.1 Using cached lxml-4.9.1.tar.gz (3.4 MB) Collecting tinycss2>=1.0.2 Using cached tinycss2-1.1.1-py3-none-any.whl (21 kB) Collecting reportlab>=3.5.42 Using cached reportlab-3.6.11.tar.gz (4.5 MB) ERROR: Command errored out with exit status 1: command: /Users/MYNAME/Documents/Python/content_creator/CC_env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/h2/xy8.... Complete output (10 lines): ##### setup-python-3.9.1-macosx-11-x86_64: ================================================ ##### setup-python-3.9.1-macosx-11-x86_64: Attempting build of _rl_accel ##### setup-python-3.9.1-macosx-11-x86_64: extensions from 'src/rl_addons/rl_accel' ##### setup-python-3.9.1-macosx-11-x86_64: ================================================ ##### setup-python-3.9.1-macosx-11-x86_64: =================================================== ##### setup-python-3.9.1-macosx-11-x86_64: Attempting build of _renderPM ##### setup-python-3.9.1-macosx-11-x86_64: extensions from 'src/rl_addons/renderPM' ##### setup-python-3.9.1-macosx-11-x86_64: =================================================== ##### setup-python-3.9.1-macosx-11-x86_64: will use package libart 2.3.21 !!!!! cannot find ft2build.h ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. -
Django when running tests ValueError: Related model cannot be resolved. Related to previous migrations issue
Had an issue with django migration files not syncing with the db (was getting column not found) due to a Model being renamed. I don't completely understand migrations but after following different stackoverflow answers - performing fake zero migrations and then adding the manual migration file: # Generated by Django 4.1 on 2022-10-10 00:47 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('campaigns', '0015_blah_blah'), ] operations = [ migrations.RenameModel("PreviousModelName", "ModelName") ] I thought the issue had been fixed. I can query the database without errors, I can add new fields to the renamed model and migrate them. Everything seemed to be working. But now I've realised that when I run python manage.py test I get the following error: Traceback (most recent call last): File "/code/manage.py", line 25, in <module> main() File "/code/manage.py", line 21, in main execute_from_command_line(sys.argv) File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv super().run_from_argv(argv) File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/test.py", line 68, in handle failures = test_runner.run_tests(test_labels) File "/usr/local/lib/python3.9/site-packages/django/test/runner.py", line 1045, in run_tests old_config = self.setup_databases( File "/usr/local/lib/python3.9/site-packages/django/test/runner.py", line 941, in …