Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to request to Gunicorn and respond with Daphne? Using Django channels, Nginx, Gunicorn, Daphne
I'm facing a strange issue in deploying Django app with Nginx, Daphne and Gunicorn. As of now, I have successfully deployed my Django app. My HTTP requests are handled by Gunicorn, and WSS requests are handled by Daphne, which is meant to happen. Consider a scenario, where I send an HTTP request to Gunicorn, and Django needs to send a message back via channels. How do I do that? For example, if I add a post via HTTP POST request, and want to send a notification via channels to all the open channels (which I have a list of) how do I make Django send back a channel message through Daphne, even when the request was HTTP in the first place received through Gunicorn? The request flow that I need is: Client > HTTP > NGINX > GUNICORN > DJANGO > Do some processing > Send notification to all open channels via WSS > Send HTTP RESPONSE OK STATUS=200 to client I used this guide to deploy https://github.com/mitchtabian/HOWTO-django-channels-daphne/blob/master/README.md Everything is working fine except I don't receive WSS messages on the client WebSocket listener, when I send a HTTP request to Gunicorn, but when I send HTTP request to Daphne I … -
Does Django allow up to two HttpResponseRedirects between views
I'm wondering if it's possible to HttpResponseRedirect from view1 to view2 and finally to view3. Psuedo code for views: class view1: HttpResponseRedirect(reverse-url-for-view2) class view2: HttpResponseRedirect(reverse-url-for-view3) class view3: #I want to end up here and maybe return a 200 Is this possible please and if not how can I do this. I'm currently able to redirect to view2 but not from view2 to view3. Thanks. -
How to relate a table to multiple other tables while still having one-to-many relationship?
Let's say I have the following model classes: # Inspection target class Target(models.Model): ... # Issue found during the inspection class Issue(models.Model): target = models.ForeignKey(Target, on_delete=models.CASCADE, related_name='issues') So, a Target can have multiple related Issues, while an Issue always relates to one Target. Now, let's say I add a new table like this: # Document that describes either a target or an issue class Document(models.Model): ... ... and I want this both Targets and Issues to have references to Documents, but a single Document can only be related to one object, either a Target or an Issue. Is this possible to do with Django? -
Building admin in Django must login with building name and password to login
I'm doing a building management program. Building Block Door No Every month, the manager receives a salary from the residents of the building. Administrator The building name and password will be entered to login and select the desired building. When building occupants check in Building will be selected Block will be selected according to the building After choosing the door number and password according to the block, the occupants will enter. I couldn't find an example for this. Thanks for your help -
Best practice for calling save() many times
When calling save many times, it works but takes a few minuts. num = 100000 for i in range(num): lu = sm.UserType(type_id=1) lu.save() In my understanding save exec the SQL. So if I can put save together, it takes a shorter time. Is there any practice for this purpose? -
Django Admin Filter if exist then exclude those items
I need to filter out with this query so that i do not have to see every items all over the World , if i could query with country specific and will see only country specific , i need help on this def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field.name == "item_name": kwargs["queryset"] = models.ItemList.objects.fliter(countries__in=[request._user_country]).exclude(countries__in=[request._user_country]) return super().formfield_for_foreignkey(db_field, request, **kwargs) -
How do I fix cmd error when trying to create a django app?
I am learning django and trying to create to use the startapp in cmd and this is the error I keep getting what am I doing wrong here? **C:\Users\green\OneDrive\Desktop\DjangoProjectsFolder>pip manage.py startapp demo_app ERROR: unknown command "manage.py" C:\Users\green\OneDrive\Desktop\DjangoProjectsFolder>python manage.py startapp demo Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.** -
Django get distinct based on rows fields group
I have a model which stores mail logs. I want to send one primary email and two reminder emails. I have separated the email logs based on the type. (first_email, first_reminder_email, second_reminder_email) What is wanted is the records to which we have sent all three emails. My model class MailLog(models.Model): MAIL_TYPE = ( ('first_email', 'First Email'), ('first_reminder_email', 'First Reminder Email'), ('second_reminder_email', 'Second Reminder Email'), ) user = models.ForeignKey('user.User', on_delete=models.CASCADE, blank=True, null=True, related_name='user_mail_log') category = models.IntegerField() # to store category mail_type = models.CharField(choices=MAIL_TYPE, max_length=100) I want to group by category, user and mail_type (should have all three status) Sample data | id | user | category | mail_type | ----------------------------------- | 1 | 20 | 4 | first_email | | 2 | 20 | 4 | first_reminder_email | | 3 | 20 | 4 | second_reminder_email | | 4 | 20 | 5 | first_email | | 5 | 22 | 4 | first_email | | 6 | 22 | 4 | first_reminder_email | I tried couple of approach MailLog.objects.filter(Q(category__id=6) & Q(mail_type='first_email') & Q(mail_type='first_reminder_email') & Q(mail_type='second_reminder_email') ) MailLog.objects.values_list('user', 'category').distinct( -
Django, Create GIN index for child element in JSON Array field
I have a model that uses PostgreSQL and has field like this: class MyModel(models.Model): json_field = models.JSONField(default=list) This field contains data like this: [ {"name": "AAAAA", "product": "11111"}, {"name": "BBBBB", "product": "22222"}, ] Now I want to index by json_field -> product field, because it is being used as identification. Then i want to create GinIndex like this: class Meta: indexes = [ GinIndex(name='product_json_idx', fields=['json_field->product'], opclasses=['jsonb_path_ops']) ] When I try to create migration, I get error like this: 'indexes' refers to the nonexistent field 'json_field->product'. How to create GinIndex that will be used for child attribute in Json Array? -
What is the proper way to send a json body with axios from React to Django Rest Api
I am trying to send a post request to my django rest API using Axios from a react frontend. Home.js Here I am getting the value from the form and setting up the state and sending the value to the function that will call the API on submit const [query, setQuery] = useState({ search: "", }) const { search } = query; // function handle submit const onSubmit = (e) => { e.preventDefault(); console.log(search); navigate(`/search/${search}`); fetchSearch(search); //fucntion that deals with the api call }; searchApi.js this function deals with api call export const fetchSearch = async (search) => { console.log("the data being recieved ", search); const config = { header: { "Content-Type": "application/json", }, }; const body = JSON.stringify({ search }); // 1 const body = { // 2 search: search, }; console.log("this is the body", body); try { let response = await axios.post(`${url}/get-teacher/`, body, config); console.log(response.data); } catch (error) { console.log(error); } }; Now let me tell you the problem I am facing, as shown above, I have comments beside the body. If I send the body //1 as a request, then django throws this error and I get an internal server error AssertionError: Expected a `Response`, `HttpResponse` or … -
How to obtain a token for a user with payload using Django Simple JWT
I can get correct token when calling the URL /token/ but I wish to create token manually for the user when /login/ is called... urls.py from django.urls import path from . import views from .views import MyTokenObtainPairView from rest_framework_simplejwt.views import ( TokenRefreshView, TokenVerifyView ) urlpatterns = [ path('', views.api_root), path('register/', views.register), path('login/', views.login), path('token/', MyTokenObtainPairView.as_view(), name='token_obtain_pair'), path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('token/verify/', TokenVerifyView.as_view(), name='token_verify'), ] views.py @api_view(['POST']) def login(request): email = request.data.get('email') password = request.data.get('password') user = get_object_or_404(User, email=email) if make_password(password) == user.password: if not user.is_active: return Response({"error": "User is not active"}, status=400) tokens = MyTokenObtainPairView.get_token(user) parse_token = { 'refresh': str(tokens), 'access': str(tokens.access_token), } return Response(status=200, data=parse_token) else: return Response(status=401) class MyTokenObtainPairSerializer(TokenObtainPairSerializer): def validate(self, attrs): data = super().validate(attrs) refresh = self.get_token(self.user) data['refresh'] = str(refresh) data['access'] = str(refresh.access_token) # Add extra responses here data['username'] = self.user.username data['groups'] = self.user.groups.values_list('name', flat=True) data['test'] = '1234' return data class MyTokenObtainPairView(TokenObtainPairView): serializer_class = MyTokenObtainPairSerializer How do I modify this line to get my token for a specific user? tokens = MyTokenObtainPairView.get_token(user) I have read the doc about manually create token by importing this: from rest_framework_simplejwt.tokens import RefreshToken but it is not adding the payload into the token... -
deepAR in python django imp[lementation
i have deepAR.wasm file,models-68-extreme.bin,deepar.js file when i tried it using a python function called AR_web_view i got an error "wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'." what can i do anybody please let me know my function def AR_web_view(request): mimetypes.add_type('application/wasm','.wasm') return render(request,"index.html") index.html is the html file where ar is loading -
ValueError: Cannot assign "1": "RecipeRequirements.ingredient" must be a "Ingredient" instance
I am working on an unguided project and I have been trying to create an instance of RecipeRequirements model but I get; ValueError: Cannot assign "1": "RecipeRequirements.ingredient" must be a "Ingredient" instance. These are the instances I want to create and I did create Ingredient instances without any error. I think I am missing something with related to foreignkey, I thought 'unique=True' would create id for each instances in the Ingredient name field, so I wouldn't have to add another _id field. I get the error after running this; recipe_requirements_1 = RecipeRequirements(ingredient=1, quantity=100.0, menu_item=1) Here is my models.py from django.db import models class Ingredient(models.Model): name = models.CharField(max_length=200, unique=True) quantity = models.FloatField(default=0) unit = models.CharField(max_length=200, default="tbsp") price_per_unit = models.FloatField(default=0.00) class MenuItem(models.Model): title = models.CharField(max_length=200, unique=True) menu_price = models.FloatField(default=0.00) class RecipeRequirements(models.Model): ingredient = models.ForeignKey(Ingredient, on_delete=models.CASCADE) quantity = models.FloatField(default=0.00) menu_item = models.ForeignKey(MenuItem, on_delete=models.CASCADE) class Purchase(models.Model): menu_item = models.ForeignKey(MenuItem, on_delete=models.CASCADE, null=True) timestamp = models.DateTimeField(auto_now_add=True, null=True) -
I am trying to add rooms feature to videocall API using Django, python, and WebRtc. But, I am getting error as below,
HTTP GET /favicon.ico/ 500 [0.11, 127.0.0.1:61656] Internal Server Error: /first/ Traceback (most recent call last): File "C:\project\videocall\venv\lib\site-packages\asgiref\sync.py", line 451, in thread_handler raise exc_info[1] File "C:\project\videocall\venv\lib\site-packages\django\core\handlers\exception.py", line 42, in inner response = await get_response(request) File "C:\project\videocall\venv\lib\site-packages\django\core\handlers\base.py", line 253, in _get_response_async response = await wrapped_callback( File "C:\project\videocall\venv\lib\site-packages\asgiref\sync.py", line 414, in call ret = await asyncio.wait_for(future, timeout=None) File "C:\Users\k Bharath Reddy\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 408, in wait_for return await fut File "C:\Users\k Bharath Reddy\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\project\videocall\venv\lib\site-packages\asgiref\sync.py", line 455, in thread_handler return func(*args, **kwargs) File "C:\project\videocall\videocallproject\videocallapp\views.py", line 11, in video return render(request, 'video.html', { File "C:\project\videocall\venv\lib\site-packages\django\shortcuts.py", line 24, in render content = loader.render_to_string(template_name, context, request, using=using) File "C:\project\videocall\venv\lib\site-packages\django\template\loader.py", line 61, in render_to_string template = get_template(template_name, using=using) File "C:\project\videocall\venv\lib\site-packages\django\template\loader.py", line 15, in get_template return engine.get_template(template_name) File "C:\project\videocall\venv\lib\site-packages\django\template\backends\django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "C:\project\videocall\venv\lib\site-packages\django\template\engine.py", line 176, in get_template template, origin = self.find_template(template_name) File "C:\project\videocall\venv\lib\site-packages\django\template\engine.py", line 158, in find_template template = loader.get_template(name, skip=skip) File "C:\project\videocall\venv\lib\site-packages\django\template\loaders\base.py", line 28, in get_template return Template( File "C:\project\videocall\venv\lib\site-packages\django\template\base.py", line 154, in init self.nodelist = self.compile_nodelist() File "C:\project\videocall\venv\lib\site-packages\django\template\base.py", line 200, in compile_nodelist return parser.parse() File "C:\project\videocall\venv\lib\site-packages\django\template\base.py", line 484, in parse raise self.error(token, e) File "C:\project\videocall\venv\lib\site-packages\django\template\base.py", line 482, in parse filter_expression = self.compile_filter(token.contents) File "C:\project\videocall\venv\lib\site-packages\django\template\base.py", … -
Are expressions return the same queryset?
I am using django ORM. Are next expressions return equal querysets? q1 = Model.objects.filter(field1=foo, field2=bar) q2 = Model.objects.filter(Q(field1=foo, field2=bar)) q3 = Model.objects.filter(Q(field1=foo) & Q(field2=bar)) q4 = Model.objects.filter(Q(Q(field1=foo) & Q(field2=bar))) -
How to solve ValueError : The given username must be set
I am trying to register a user using Python Django. Validations are provided using JavaScript. When a user enter his or her details and click the sign up button, the data will be stored in the database. Suppose if a user click on the sign up button without entering their details, I am getting an error like below. ValueError at /Accounts/CandidateRegister/ The given username must be set Request Method: POST Request URL: http://127.0.0.1:8000/Accounts/CandidateRegister/ Django Version: 4.0.2 Exception Type: ValueError Exception Value: The given username must be set Exception Location: C:\job\venv\lib\site-packages\django\contrib\auth\models.py, line 137, in _create_user Python Executable: C:\job\venv\Scripts\python.exe Python Version: 3.9.7 Python Path: ['C:\\job\\jobsite', 'C:\\Users\\Student\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\Student\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\Student\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\Student\\AppData\\Local\\Programs\\Python\\Python39', 'C:\\job\\venv', 'C:\\job\\venv\\lib\\site-packages'] Server time: Tue, 19 Apr 2022 10:51:00 +0530 I did not understand why this error occurs even if the JavaScript validation provided. Can anyone have any idea to solve this issue. html <form style="padding:10px 25%;" class="signup-form" id="candidate" name="candidate" method="POST" action="{% url 'candidateregister' %}"> {% csrf_token %} <div class="form-row"> <div class="form-group col-md-6"> <label for="cafname" style="font: normal normal normal 14px Poppins;">First name</label> <input type="text" class="form-control" id="cafname" name="cafname" placeholder="Your first name" style="font-family:sans-serif;border:2px solid #d4d2d2;"> <span id="lfname" class="regval"></span> </div> <div class="form-group col-md-6"> <label for="calname" style="font: normal normal normal 14px Poppins;">Last name</label> <input type="text" class="form-control" id="calname" … -
A Javascript & Python web image capture with time caprure placed in order
I'm trying to create a web image capture in python (Django if needed) that takes a photo and displays the record of the time capture with the picture taken, and arranges every picture taken in a chronological order. .A Web page that allows capturing images using cellphone. .The images are submitted along with time of capture, for record keeping purpose. .Another page allows viewing thos images chronologically. #here is the code of my camera capture #tried adding time capture with chronologically slideshow but I experienced major errors #I hope to hear some feedback (Thank you in advance) import cv2 as cv cam_port = 0 cam = cv.VideoCapture(cam_port) result, image = cam.read() if result: cv.imshow("freetry", image) cv.imwrite("freetry.png", image) cv.waitKey(0) cv.destroyWindow("freetry") else: print("No image" -
AssertionError: 302 != 200 : Couldn't retrieve redirection page '/api/v2/app/nextdialog': response code was 302 (expected 200)
AssertionError: 302 != 200 : Couldn't retrieve redirection page '/api/v2/app/nextdialog': response code was 302 (expected 200) In DJango is it possible to have three views where each one redirects to the next. View 1 redirects to view 2 and view 2 redirects to view 3? Views.py: class ConversationLayerView(generics.GenericAPIView): permission_classes = (permissions.IsAuthenticated,) def post(self, request, *args, **kwargs): body = request.data cardType = body["cardType"] if cardType == "CHOICE": serializer = appChoiceTypeSerializer(body) elif cardType == "TEXT": serializer = appTextTypeSerializer(body) elif cardType == "INPUT": serializer = appInputTypeSerializer(body) else: serializer = StartAssessmentSerializer(body) validated_body = serializer.validate_value(body) url = get_endpoint(validated_body) reverse_url = encodeurl(body, url) return HttpResponseRedirect(reverse_url) class NextDialog(generics.GenericAPIView): permission_classes = (permissions.AllowAny,) def get(self, request, *args, **kwargs): result = request.GET data = result.dict() contact_uuid = data["contact_uuid"] step = data["step"] value = data["value"] description = data["description"] title = data["title"] if data["cardType"] == "CHOICE": optionId = int(value) - 1 else: optionId = data["optionId"] path = get_path(data) assessment_id = path.split("/")[-3] request = build_rp_request(data) app_response = post_to_app(request, path) if data["cardType"] != "TEXT": if data["cardType"] == "INPUT": optionId = None store_url_entry = appAssessments( contact_id=contact_uuid, assessment_id=assessment_id, title=title, description=description, step=step, user_input=value, optionId=optionId, ) store_url_entry.save() pdf = pdf_ready(app_response) if pdf: response = pdf_endpoint(app_response) return HttpResponseRedirect(response) else: message = format_message(app_response) return Response(message, status=status.HTTP_200_OK) class Reports(generics.GenericAPIView): permission_classes = … -
Intercept specific function invocations using parent/child classes?
I am writing a framework that allows us to intercept certain function invocations so that we can manage them(enforce timeouts and retries, persist return values etc.). Right now I'm thinking of introducing an abstract class with a method that invokes an abstract method and forcing users/clients to inherit the abstract class and do their function invocations inside the abstract method. Specifically, I am writing an abstract class Fruit that expects clients to: Extend Fruit and override the eat_fruit method Invoke the eat method when actually wanting to use the overriden eat_fruit method The reason I'm thinking of doing this is that we want to record the number of eat_fruit invocations class Fruit: def eat(self, *args, **kwargs): self.eat_fruit(*args, **kwargs) def eat_fruit(self, *args, **kwargs): pass class Apple(Fruit): def eat_fruit(self, *args, **kwargs): print("Eat Apple") apple = Apple() apple.eat() However, we're running into a problem with extensibility. Let's say the client needs to add input parameter color to Apple's eat_fruit method, they can add it like this: class Fruit: def eat(self, *args, **kwargs): self.eat_fruit(*args, **kwargs) def eat_fruit(self, *args, **kwargs): pass class Apple(Fruit): def eat_fruit(self, color, *args, **kwargs): print("Eat "+ color + " Apple") apple = Apple() apple.eat("Red") This is workable but relies on them … -
Django is trying to authenticate Wrong user for AWS RDS and failing
I am hosting a postgresql database on AWS using the RDS service. I am trying to connect the django project to the aws database using the settings.py file in the django project. I keep getting the following error: connection to server at "database-1.xxxxxx.us-east-1.rds.amazonaws.com" (xx.xxx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user "local_user" This error is unexpected because it should not be trying to authenticate the local_user as this is the user for my local postgres server, it should be trying to authenticate the user for the hosted database, which is completely different. This is what my settings file looks like: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': os.environ.get('DATABASE_NAME'), 'USER': os.environ.get('DATABASE_USER'), 'PASSWORD': os.environ.get('DATABASE_PASSWORD'), 'HOST': "database-1.xxxxxx.us-east-1.rds.amazonaws.com", 'PORT': 5432 } } I can't figure out what the issue seems to be. Any help will be appreciated! -
Django view.py, how to remove an item from a nested dict before returning the response to react?
Currently I have a function in view.py handling POST request from react. I want to remove an item from a nested dict before sending the reponse back to react. My view.py: @api_view(['GET', 'POST']) def TableViewList(request): if request.method == 'POST': serializer = TabelSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) The response from console.log on my frontend is like this: {data: {…}, status: 201, statusText: 'Created', headers: {…}, config: {…}, …} config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …} data: {id: 121, position: 'Position 3', defect: 'Defect 3', tool: 'Tool 3', created_at: '2022-04-19T03:10:55.724869Z'} headers: {allow: 'POST, GET, HEAD', content-length: '113', content-type: 'application/json', cross-origin-opener-policy: 'same-origin', date: 'Tue, 19 Apr 2022 03:10:55 GMT', …} request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …} status: 201 statusText: "Created" [[Prototype]]: Object I really want to delete the "created_at" before sending the reponse back to the react. I have tried many ways, such as, .pop() & del. But no luck. Do anybody know how to do it? -
Forbidden for url error from http://schemas.xmlsoap.org/soap/encoding/
I am getting this "Forbidden for url" error when using zeep. Does someone knows what the root cause is? I have tried to use some options from the Client object of zeep but to no avail. Or is it something wrong in my WSDL file? The strange part is that this code used to work fine a few months ago, and suddenly started getting this error. This is the trace back from the error: Traceback (most recent call last): File "/usr/src/app/attpcdaq/daq/tasks.py", line 33, in eccserver_refresh_state_task ecc_server.refresh_state() File "/usr/src/app/attpcdaq/daq/models.py", line 428, in refresh_state client = self._get_soap_client() File "/usr/src/app/attpcdaq/daq/models.py", line 308, in _get_soap_client return EccClient(self.ecc_url) File "/usr/src/app/attpcdaq/daq/models.py", line 65, in __init__ client = SoapClient(wsdl_url) # Loads the service definition from ecc.wsdl File "/usr/local/lib/python3.7/site-packages/zeep/client.py", line 73, in __init__ self.wsdl = Document(wsdl, self.transport, settings=self.settings) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 92, in __init__ self.load(location) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 97, in load root_definitions = Definition(self, document, self.location) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 193, in __init__ self._load(doc) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 198, in _load self.parse_types(doc) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/wsdl.py", line 330, in parse_types self.types.add_documents(schema_nodes, self.location) File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 111, in add_documents document = self.create_new_document(node, location) File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 195, in create_new_document schema.load(self, node) File "/usr/local/lib/python3.7/site-packages/zeep/xsd/schema.py", line 421, in load visitor.visit_schema(node) File "/usr/local/lib/python3.7/site-packages/zeep/xsd/visitor.py", line 165, in … -
django rest framework api detect request source Like Mobile or WEB in
How to Detect Either browser request or other by by Django REST viewsets.ModelViewSet -
Account Inactive Page Not Working in django-allauth
I have successfully setup an authentication system with django application using the popular django-allauth package. I suspended a registered user by updating SuspendedUser.is_active=False but whenever I try to login as the suspended user I'd get the failed authentication message The username and/or password you specified are not correct.. Do I need any special configuration to display the account_inactive.html template as I cannot find anything that mentions that in the official documentation?. Note: django-allauth version is 0.49.0 and django version is 4.0.3 -
Why doesn't Django automatically create the templates folder?
when I use django2.0 I met an error:django.template.exceptions.TemplateDoesNotExist: name.html. I find the problem is that the django didn't create the template directory automatically. I use commanddjango-admin startproject demo to start my project, but I can't see the template directory as tutorial. May I ask what's the problem?