Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable
I am trying to host a django website in gcloud... i did some changes in settings.py file this is my code DATABASES = {"default": env.db()} # If the flag as been set, configure to use proxy if os.getenv("USE_CLOUD_SQL_AUTH_PROXY", None): DATABASES["default"]["HOST"] = "127.0.0.1" DATABASES["default"]["PORT"] = 5432 after adding this code into settings.py file i am facing below error File "C:\Users\CHANDU\Downloads\Unisoftone\unisoftone\website\website\settings.py", line 99, in <module> DATABASES = {"default": env.db()} File "C:\Users\CHANDU\AppData\Local\Programs\Python\Python38-32\lib\site- packages\environ\environ.py", line 208, in db_url return self.db_url_config(self.get_value(var, default=default), engine=engine) File "C:\Users\CHANDU\AppData\Local\Programs\Python\Python38-32\lib\site- packages\environ\environ.py", line 281, in get_value raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable -
is it possible for a cookie to be deleted by itself?
I have this website that uses react, django Its an ecommerce so once they want to pay for the product all off the cookies being deleted what happens behind the scenes is once they place an order it will generate an transactionId when user click the Pay now button to pay the order they will go to another website to place their credit card and pay then that transactionId will be stored in the cookies to verify, see if the order is payed or not if it is payed then it will make the order as a payed order for the user The problem is once they go for placing their credit card on another website all of the cookies of my website being cleared what is the problem Here is a example of my cookie setCookie("transId", `${orderId}`, { path: "/", expires: new Date(new Date().valueOf() + 1000 * 60 * 60 * 1000), sameSite: "lax", secure: true, }); this setCookie is coming from react-cookie package can you see where is my problem ? is it because cookie is not httpOnly or something else is the problem I realy need your help :)) thanks -
Autenticate() function return None to superuser as well
def student_login(request): if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user1 = authenticate(request, username=username,passsword=password) print(user1) if user1 is not None: print('Valid User') login(request , user1) return redirect('/meetups/student_profile') else: print('Invalid USer') return render(request, 'meetups/student_login.html') return render(request, 'meetups/student_login.html') If I print username and password it returns correct credentials but still didn't authenticate -
csrf tken and access token deleted from cookies and session storage after page refresh in django rest framework and react/redux
I ran into a weird problem when implementing httponly with simple_jwt, csrf token is saved in cookies when user logged out, and access token in sessions storage, but after that when the user performs a page refresh or changing the page, both are deleted. everything is fine in postman and here what i'm receiving in postman here is my code : Views def get_tokens_for_user(user): refresh = RefreshToken.for_user(user) return { 'refresh': str(refresh), 'access': str(refresh.access_token), } class LoginView(APIView): def post(self, request, format=None): data = request.data response = Response() email = data.get('email', None) password = data.get('password', None) user = authenticate(email=email, password=password) if user is not None: if user.is_active: data = get_tokens_for_user(user) response.set_cookie( key = settings.SIMPLE_JWT['AUTH_COOKIE'], value = data["access"], expires = settings.SIMPLE_JWT['ACCESS_TOKEN_LIFETIME'], secure = settings.SIMPLE_JWT['AUTH_COOKIE_SECURE'], httponly = settings.SIMPLE_JWT['AUTH_COOKIE_HTTP_ONLY'], samesite = settings.SIMPLE_JWT['AUTH_COOKIE_SAMESITE'] ) csrf.get_token(request) response.data = {"Success" : "Login successfully","data":data, "status":200} data.update({'id': user.id}) data.update({'patronymic': user.patronymic}) data.update({'firstname': user.first_name}) data.update({'lastname': user.last_name}) return response else: return Response({"No active" : "This account is not active!!"}, status=status.HTTP_404_NOT_FOUND) else: return Response({"Invalid" : "Invalid email or password!!"}, status=status.HTTP_404_NOT_FOUND) Settings.py 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', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ] from corsheaders.defaults import default_headers CORS_ALLOW_HEADERS = list(default_headers) + [ 'X-CSRFTOKEN', ] ROOT_URLCONF = 'backend.urls' from datetime import timedelta SIMPLE_JWT = … -
I need help on django trying to run runserver gives an error
please help me I'm trying to run python manage.py runserver and gives such an error I will be grateful for any help enter image description here AttributeError: 'function' object has no attribute 'CharField' -
Caching serializer responses in Django Rest Framework
I am using serializer to get the related data for a particular resource like this: SessionSerializer.py def to_representation(self, instance): response = super().to_representation(instance) response["user"] = UserSerializer(instance.user).data if instance.experiment: response["experiment"] = ExperimentSerializer(instance.experiment).data response["last_event"] = EventSerializer(instance.last_global_event).data # fetch and return all session answers tied to this session response["session_answers"] = instance.sessionanswer_set.values() return response I am also using DRF cache decorators in the SessionViewSet, which seems to be working fine. However, I cannot invalidate the cache data when there is an update to the instance and/or if there is an update to any related instance (like user). Is there a standard practice or documentation for how to clear cache data when there is an update? -
How to prevent user from redirecting to restricted page in django
I have created a login page for my website, but when I manually type in the URL like http://127.0.0.1:8000/home/, it will redirect them to the home page even when they have not login yet, how do I prevent this from happening? Views.py def login_user(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 and user.is_admin: login(request, user) messages.success(request, "You have login to admin page") return redirect('home') elif user is not None and user.is_customer: # authenticated if user is a customer service login(request, user) return redirect('customer') # redirect the user to the customer service page elif user is not None and user.is_logistic: # # authenticated if user is a logistic messages.success(request, "You have login to logistic page") login(request, user) return redirect('logistic') # redirect the user to the logistic page else: messages.success(request, "try Again") return redirect('login') else: return render(request, 'authenticate/login.html') urls.py urlpatterns = [ path('', views.login_user, name='login'), path('home/', views.home, name='home'), path('logout/', views.logout_view, name='logout'), path('register/', views.register_view, name='register'), path('edit-register/', views.edit_register_view, name='edit_register'), path('change-password/', views.password_change, name='password_change'), path('reset-password/', views.PasswordReset.as_view(), name='password_reset'), path('reset-password-done/', views.PasswordResetDone.as_view(), name='password_reset_done'), path('reset-password/<uidb64>/<token>/', views.PasswordResetConfirm.as_view(), name='password_reset_confirm'), path('reset-password-complete/', views.PasswordResetComplete.as_view(), name='password_reset_complete'), ] forms.py class LoginForm(forms.Form): username = forms.CharField( widget=forms.TextInput( attrs={ "class": "form-control" } ) ) password = forms.CharField( … -
how to change inside dictionary in python
i have data like this : [{'a':1 , 'b': 1 , 'c':{'ca' : 11 , 'cb':21}}, {'a':2 , 'b': 2 , 'c':{'ca' : 12 , 'cb':22}}, {'a':3 , 'b': 3 , 'c':{'ca' : 13 , 'cb':23}}, {'a':4 , 'b': 4 , 'c':{'ca' : 14 , 'cb':24}}, ] i wanted to ask how to change dictionary inside dictonary data in python , for example I want to change 'ca' where a='3' to 33 , so I want to change data like this : [{'a':1 , 'b': 1 , 'c':{'ca' : 11 , 'cb':21}}, {'a':2 , 'b': 2 , 'c':{'ca' : 12 , 'cb':22}}, {'a':3 , 'b': 3 , 'c':{'ca' : 33 , 'cb':23}}, {'a':4 , 'b': 4 , 'c':{'ca' : 14 , 'cb':24}}, ] -
How to set Django social Auth for Google OAuth2 to only able to login with company email address
As of now any user with gmail account are able to log in in my django application , whereas I want to restrict the user with company domain can only login through gmail in my application. example: Allowed: akashrathor@example.com xyz@xyzcompany.com abcdefgh@abccompany.com not allowed: abcd@gmail.com as far as my settings.py are set as: INSTALLED_APPS = [ 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', ] SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.social_user', 'social.pipeline.user.get_username', 'social.pipeline.user.create_user', 'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.load_extra_data', 'social.pipeline.user.user_details' ) SOCIAL_AUTH_DISCONNECT_PIPELINE = ( 'social.pipeline.disconnect.get_entries', 'social.pipeline.disconnect.revoke_tokens', 'social.pipeline.disconnect.disconnect' ) AUTHENTICATION_BACKENDS = [ 'allauth.account.auth_backends.AuthenticationBackend', ] SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': [ 'profile', 'email', ], 'AUTH_PARAMS': { 'access_type': 'online', } } } SITE_ID = 1 LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/' my urls.py from django.urls import path,include from django.contrib.auth.views import LogoutView urlpatterns = [ path('accounts/', include('allauth.urls')), path('logout', LogoutView.as_view(),name="logout"), ] -
RecursionError:maximum recursion depth exceeded while calling a Python object in my Django web applications
I've been struggling with this issue for a while now. Each time I run python management.py runserver and navigate to the page with my web applications actual data, it suddenly breaks and gives the above error prompt models.py from django.db import models from django.urls import reverse from equipments .models import Equipment class TruckIssue(models.Model): description = models.CharField(max_length=100) part_number = models.CharField(max_length=100, blank=True) uni = (('MTR', 'Meter'), ('NO', 'Number')) unit = models.CharField(choices=uni, max_length=6, null=True, default="no") quantity = models.IntegerField(null=True) equipments = models.ForeignKey(Equipment, on_delete=models.CASCADE) date_posted = models.DateTimeField(auto_now_add=True) mechanic = models.CharField(max_length=10, default="no") job_card = models.CharField(max_length=10, default="no") remark = models.TextField(blank=True, default="no") def __str__(self): return f'{self.equipments} Issues' views.py from django.views.generic import ListView from .models import TruckIssue class TruckIssueListView(ListView): model = TruckIssue template_name = "truck/issue_list.html" context_object_name = 'truckissues' ordering = ['-date_posted'] paginate_by = 20 urls.py from django.urls import path from . import views from .views import TruckIssueListView urlpatterns = [ path('', TruckIssueListView.as_view(), name='issues'), ] I've tried recreating the web app on different occasions but all keep running into the same error. I'm using django 3.2.5 -
ORDER BY table structure instead of numerical
My current MsSQL query looks like this : all = 'SELECT Master_Sub_Account , cAccountTypeDescription , Debit , Credit FROM [Kyle].[dbo].[PostGL] AS genLedger'\ ' Inner JOIN [Kyle].[dbo].[Accounts] '\ 'on Accounts.AccountLink = genLedger.AccountLink '\ 'Inner JOIN [Kyle].[dbo].[_etblGLAccountTypes] as AccountTypes '\ 'on Accounts.iAccountType = AccountTypes.idGLAccountType'\ ' WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122)'\ ' AND genLedger.TxDate > ?'\ ' ORDER BY iAccountType' I would need the ORDER BY iAccountType to show the order that the data is placed in the table , not numerical. Currently the output looks like this (see Account column): But I need it to look like this: -
How can i iterate two django models
I have multiple models in my django project. i want to iterate them all so i can access it in django model field. how can i do this? I have tried zipping them like in my views.py like: inventory = Inventory.objects.all() header = Header.objects.all() setup = Setup.objects.all() revision = Revisions.objects.all() spec = SpecificationDetails.objects.all() review = Reviewers.objects.all() zippedItems = zip(inventory, header, setup, revision, spec, review) context = { 'zippedItems': zippedItems } return render(request, 'crud/dashboard.html', context) and in my template file i tried {%for items in zippedItems %} <td>{{items}}</td> but it's not working and i think it did not zipped the objects. any tips on how can i achieve this? -
Sorting by date in MsSQL Queries || Django || Python
I am trying to sort the data fetched by the below MsSQL statements by date (1 year from today) My current statement looks like this: one_yrs_ago = datetime.now() - relativedelta(years=1) all = 'SELECT Master_Sub_Account , cAccountTypeDescription , Debit , Credit FROM [Kyle].[dbo].[PostGL] AS genLedger'\ ' Inner JOIN [Kyle].[dbo].[Accounts] '\ 'on Accounts.AccountLink = genLedger.AccountLink '\ 'Inner JOIN [Kyle].[dbo].[_etblGLAccountTypes] as AccountTypes '\ 'on Accounts.iAccountType = AccountTypes.idGLAccountType'\ ' WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122)'\ ' AND WHERE genLedger.TxDate > ' + one_yrs_ago However, this returns multiple errors no matter how I change the statement. Does anyone know how to sort by date in mssql queries like the above ? -
Add Other Fields of AUTH_USER model with SimpleJWT in Django Rest Framework
I'm using Django Rest Framework with Simple JWT. All i want to do is fetch or add extra field (eg. first_name, last_name) with Refresh & Access Token. I want to use AUTH_USER model and not the Custom User model. I tried custom TokenObtainPairViewbut still not working and i'm only getting is Refresh & Access Token. When checked on jwt.io it shows only id. Can anyone please help. Is there anything left on my side to do. Please help { "token_type": "access", "exp": 1631511174,"jti":"13b76d1d5e2a4d978cc19fabbdc0fc9e", "user_id": 3 } Views.py from rest_framework_simplejwt.views import TokenObtainPairView class TokenObtainPairView(TokenObtainPairView): # Replace the serializer with your custom serializer_class = MyTokenObtainPairSerializer # token_obtain_pair = TokenObtainPairView.as_view() serializers.py class MyTokenObtainPairSerializer(TokenObtainPairSerializer): def validate(self, attrs): data = super().validate(attrs) refresh = self.get_token(self.user) data['refresh'] = str(refresh) data.pop('refresh', None) # remove refresh from the payload data['access'] = str(refresh.access_token) # Add extra responses here data['username'] = self.user.username data['first_name'] = self.user.first_name data['last_name'] = self.user.last_name return data -
how to run django selenium automated scripts in cpanel
I have developed and deployed the Django app for selenium automation, which automatically opens the selenium chrome browser and extracts the data from a website. It works perfectly in the localhost server but when I deployed it into the Cpanel server it's giving "500 Internal Server Error" def startfunc(request): if request.method == "GET" : chrome_options = webdriver.ChromeOptions() chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") chrome_options.add_argument("--headless") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--no-sandbox") driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), options=chrome_options) driver.get("https://www.indiatoday.in/india?page&view_type=list") or, I am trying this way as well def startfunc(request): if request.method == "GET" : driver = webdriver.Chrome(ChromeDriverManager().install()) driver.get("https://www.indiatoday.in/india?page&view_type=list") -
Not Able to change css using JS
I am working on DJango which also Involves JavaScript I need to change background color of an element after a certain action but am unable to do so. Below code is the only Javascript file used in the project. function create_email(email){ const element = document.createElement('div'); element.id = "email"; element.innerHTML= `<b>${email.sender}</b>: ${email.subject}<p id='right' ><button id ="view" onclick="view_mail(${email.id})"class="btn btn-primary">View</button>${email.timestamp}<button id="archive" onclick="archive(${email.id})" class="btn btn-secondary">Archive</button><p>`; element.addEventListener('click', function() { console.log(`This message is sent by ${email.sender}`) }); document.querySelector('#emails-view').append(element); } Above I created an Element div using Javascript and assign id email , Later I will be changing this elements css property:- function read(id){ fetch(`/emails/${id}`, { method: 'PUT', body: JSON.stringify({ read: true }) }) document.getElementById("email").style.backgroundColor="red"; } In this function I tried changing the background color of the element but is not changing anything. Note that this function is running as I have tried changing other elements property in this function only and they worked. The element email div is within the div with id emails-view . And I am able to change the background of emails-view div but not email div that is within this div block. -
DJANGO - Upload image and then display on template
I'm trying to display the 'plant_image' within the for loop on dashboard.html. I can get all other fields to display but the image will not. I understand there is some difference between development and production, but I just want to have it work in development for the moment. If someone could explain how to make this work, I would be very grateful. model.py class Plant(models.Model): plant_name = models.CharField(max_length=30) plant_image = models.ImageField(upload_to ='upload/', height_field=None, width_field=None, max_length=None) dashboard.html - template {% for plant in plants %} <p>/{{plant.plant_name}}</p> <img src="{{plant.plant_image}}" alt="Plant Image" width="250" height="250"> {% endfor %} views.py def dashboard(request): plants = Plant.objects.all() return render(request, 'dashboard.html', {'plants': plants}) urls.py urlpatterns = [ path('', views.dashboard, name='dashboard'), ] -
403 (Forbidden) when trying to access DRF API from React js
I started to use django recently and I also tried to use React js and I wanted to do something simple like a nav var in React. For that I would need to fetch the user information which I have on a DRF API as follows in the views file: ALLOWED_HOSTS = settings.ALLOWED_HOSTS @api_view(['GET']) @authentication_classes((SessionAuthentication, TokenAuthentication)) @permission_classes((IsAuthenticated,)) def user_details_view(request, *args, **kwargs): current_user = request.user id = current_user.id status = 200 data = dict() try: obj = CustomUser.objects.get(id=id) data = UserSerializer(obj) # data = obj.serialize() except: data['message'] = "Not Found" status = 404 return Response(data.data, status=status) The urls are set up and if I access it in the django server it works fine but when I try on react: function loadUserInfo(callback){ const xhr = new XMLHttpRequest(); const method = 'GET'; const url = "http://127.0.0.1:8000/userdetails/"; const responseType = "json"; xhr.responseType = responseType; // Let the xhr request know that its getting a json xhr.open(method, url); //This opens the request with the method and url entered xhr.onload = function(){ console.log("This is the response: ",xhr.response) callback(xhr.response, xhr.status) } xhr.onerror = function(){ callback({"message":"The request was an error"}, 400) } xhr.send();//Trigger that request } I call the function in App() but I get: GET http://127.0.0.1:8000/userdetails/ 403 … -
Url not being resolved in, 404 error django
I am not able to create an detail and update view using the <pk> and <pk>/update/, this is my url paths. urlpatterns = [ path('',views.IndexView.as_view(), name='index'), path('form/',views.CompanyView.as_view(),name='company'), path('<pk>/',views.CompanyDetailView.as_view()), path('<pk>/update/',views.CompanyUpdateView.as_view()) ] my views looks like this, class CompanyUpdateView(generic.UpdateView): model = Company fields = '__all__' success_url = '/company' class CompanyDetailView(generic.DetailView): model = Company fields = '__all__' Also I use a FormView to add the data to database, class CompanyView(generic.FormView): form_class = CompanyForm template_name = 'company/company.html' success_url = '/company' def form_valid(self, form): form.save() return super().form_valid(form) When I got to a url company/1/ or company/1/update I get a 404 error. What would be the reason for it and how to solve this -
'-' in a model field on the django admin page instead of the form data
The Port Name column is currently empty with just a '-' at the moment. I was able to get the form input in this column earlier but now I just get the '-'. Here is a screenshot of what I get in the admin page. -
How do I get bearer token from DRF using React?
I have a backend built using DRF, and frontend using React and axios. Once someone logs in, the server issues a csrf token and session id. Is there anyway I can extract the server-generated Bearer token? -
django form.is_valid returns false when while using XMLHttpRequest
since bootstrap 5 no longer ships with jquery and recommends using the vanilla javascript XMLHttpRequest() to make dynamic requests that is what I am trying to do in django. All the other examples of doing this use the traditional .$ajax. I have a basic javascript function: function sendPhoneVerification(_phone) { var http = new XMLHttpRequest(); const params = { phone: _phone } http.open('POST', '/approvephone/', true) http.setRequestHeader("X-CSRFToken", "{{ csrf_token }}"); http.setRequestHeader('Content-type', 'application/json') http.setRequestHeader('phone', _phone) http.send(JSON.stringify(params)) http.onload = function() { alert(http.responseText) } } The CSRF middlware token is working fine, but the in the view, the form.is_valid() returns false and the error is that required field "phone" is missing. I can't tell how I am supposed to provide that value. The form being tested against is a simple form with one field class AddPhoneForm(forms.Form): phone = PhoneNumberField() relevant part of the view @csrf_protect @login_required def approvephone(request): if request.method == 'POST': form = AddPhoneForm(request.POST) if form.is_valid() #returns false and error is missing field "phone" Any idea how I can correctly provide the phone fields in the POST response to make django happy? -
How to serialize my model to get desired output
I want to serialize my model which having multiple object. I want to nest them. this is my model class model8(): country = foreign key a_image = "ImageField" b_image = "ImageFiled" a_url = char filed b_url = char filed and my desired output is { “ a_images”:[ { “image”: “”, “url”: “” }, { “image”: “”, “url”: “” } ], “b_images”:[ { “image”: “”, “url”: “” }, { “image”: “”, “url”: “” } ] } can any one help solve this huddle -
saving value of one model field count to another field of the same model during save
I am working on a pool app and want to add the total_likes attribute to the model which will allow me to count the number of users who liked the question just like Youtube community question allows. I just tried to override the save(*args, **kwargs) but got many error. what should I do now from django.db import models from django.contrib.auth.models import User class Question(models.Model): enter code here text = models.TextField() voters = models.ManyToManyField(to=User, blank=True, related_name='voters') impression = models.CharField(max_length=30, choices=impression_choices, blank=True, null=True) date_created = models.DateTimeField(auto_now_add=True) likes = models.ManyToManyField(to=User, related_name='likes', blank=True) total_likes = models.IntegerField(default=0) def __str__(self): return self.text def save(self, *args, **kwargs): self.total_likes = self.likes_set.count() super().save(*args, **kwargs) The Model below works totally fine. In the model above I tried to override the save() method but don't know how to? class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) text = models.CharField(max_length=20) votes = models.IntegerField(blank=True, default=0) def __str__(self): return self.text -
Django - Settings.py, urls.py and views.py resulting in 404 error
Recently I came across a 404 error when running my Django Project. I can't figure it out for some reason and I need help. I'm new to django and coding in general. Here is the error Using the URLconf defined in portfolio.urls, Django tried these URL patterns, in this order: admin index.html [name='index'] experience.html [name='experience'] projects.html [name='projects'] research.html [name='research'] education.html [name='education'] 404.html [name='comeback'] design.html [name='design'] The empty path didn’t match any of these. Here is the program code. Here is views.py from django.shortcuts import render def index(request): return render(request, 'index.html', {}), def experience(request): return render(request, 'experience.html', {}), def projects(request): return render(request, 'projects.html', {}), def research(request): return render(request, 'research.html', {}), def education(request): return render(request, 'education.html', {}), def comeback(request): return render(request, '404.html', {}), def design(request): return render(request, 'design.html', {}), Here is urls.py (app) from django.urls import path from . import views urlpatterns = [ path('index.html', views.index, name="index"), path('experience.html', views.experience, name="experience"), path('projects.html', views.projects, name="projects"), path('research.html', views.research, name="research"), path('education.html', views.education, name="education"), path('404.html', views.comeback, name="comeback"), path('design.html', views.design, name="design"), ] Here is urls.py (where settings is) from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('app.urls')), ] Here are the settings.py import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent …