Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
'Tag' object has no attribute 'count' in for loop
I am building a BlogApp and I am trying to create a notification when a particular tag is used 10 times. So i am using if statement in for loop so if any tag used 10 times then create notification But when i try to count then it is showing 'Tag' object has no attribute 'count' models.py class Post(models.Model): post_user = models.ForeignKey(User, on_delete=models.CASCADE) psot_title = models.CharField(max_length=30) class Comment(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post_of = models.ForeignKey(Post, on_delete=models.CASCADE) views.py def page(request): subquery = Tag.objects.filter(post__post_user=request.user).annotate( num_name=Count('name') for que in subquery: if que.count() > 10: Notification.objects.create(user=request.user) context = {'subquery':subquery} return render(request, 'page.html', context} What have i tried :- I also tried len like :- for que in subquery: if len(que) > 10: Notification.objects.create(user=request.user) But it showed object of type 'Tag' has no len() I have tried many times by removing count() and len() but it showed 'int' object has no attribute 'name' Any help would be much Appreciated. Thank You -
Django: How to pass js variable to html template as tag
My task is to send the result of the test, created using javascript, to the html-template to use it in the {% if mark> = 4%} tag, in order to write to the database that the test is passed. I tried composing an ajax request but not sure if it is correct. views.py def practice(request, lesson_id): form = LessonDone() posts = get_object_or_404(Lessons, pk=lesson_id) lessonid = Lessons.objects.get(pk=lesson_id) mark = request.POST.get('url') if request.method == 'POST': p, created = DoneLessonsModel.objects.get_or_create( user=request.user, lessons=lessonid, defaults={'done': True}, ) form = LessonDone(request.POST, instance=p) if form.is_valid(): try: form.save() return redirect('practice') except: form.add_error(None, 'Ошибка') context = {'posts': posts, 'form': form, 'mark': mark} return render(request, 'landing/../static/practice.html', context) urls.py ... path(r'lesson/<int:lesson_id>/practice/', views.practice, name='practice'), ... practice.html ... <div class="buttons "> <button class="restart btn-dark">Перепройти тест{{ mark }}</button> {% if mark >= 4 %} <form action="" method="POST"> {% csrf_token %} {{ form }} {% endif %} <button class="quit btn-dark" type="submit" value="Submit" id="send-my-url-to-django-button">Выйти</button> {% if mark >= 4 %} </form> {% endif %} </div> ... </script> <script type="text/javascript"> $(document).ready(function() { var url = userScore; $("#send-my-url-to-django-button").click(function() { $.ajax({ url: {% url 'practice' posts.pk %}, type: "POST", dataType: "json", data: { url: url, csrfmiddlewaretoken: '{{ csrf_token }}' }, success : function(json) { alert("Successfully sent the URL to … -
How to restrict staff unauthorize access to admin page django?
I have created my admin page, so when the admin login it will redirect them to this url http://127.0.0.1:8000/home/, but the admin can change the url to http://127.0.0.1:8000/logistic/ after they login, how to prevent this from happen? Any help would be appreciated -
Connect c# windows app to django website with api
i have a Django website and a c# windows application , i want to create encrypted web api and read this api in my c# win app, the most important thing is security , i want a solution to do it , -
How to manage Django form validation with dynamically generated forms
Let's say I have the following html page: LIVE CODE Let's say that in each row there is a form (I have to implement it), How can I do so that when I click on 'save' button (also to be implemented) all the inputs of each row are sent in the request.POST and I can process them individually in the backend. This is my view for a new expense: def new_expense(request): data = { 'title': "New Expense", } data['projects'] = Project.objects.filter(is_visible=True).values('id') data['expense_category'] = dict((y, x) for x, y in EXPENSE_CATEGORY) data['expense_type'] = dict((y, x) for x, y in EXPENSE_TYPE) form = ExpenseForm() if request.method == "POST": reset = request.POST['reset'] form = ExpenseForm(request.POST) if form.is_valid(): form.save() if reset == 'true': form = ExpenseForm() data['form'] = form return render(request, "expense/new_expense.html", data) I would like to create a similar view for multiple new expense creation. -
Django Templates - How to auto increment an integer?
I'm using Django with Alpine.js. I'm trying to loop over users' images from 1 to 20. For instance, 'user-1.jpg', 'user-2.jpg', and so on and so forth. The following is, of course, not working, but at least it will give you a sense of what I'm trying to achieve: {% load static %} <template x-for="(item, index) in items" :key="index" hidden> <img class="absolute rounded-full z-10 animate-float" :style="item.style" :src="`{% static img/user-${index+1}.jpg %}`" :width="item.size" :height="item.size" :alt="`User ${index+1}`" @mouseenter="active = index; commentOn = true" @mouseleave="commentOn = false" /> </template> I know that I probably should use {{ forloop.counter }} but I'm not sure how exactly should I use it in this type of context. -
Fetching data from outside API with Authorization key in Django
I am trying to fetch data from outside API with post method in django. in my views.py I can fetch data with: response = requests.post('https://url_address').json() It works totally fine for simple APIs but when come to authorized API, i.e. I need to put some value like Content-Type, Authorization in header in postman or some command in body->raw in postman, I can't fetch data with the aforementioned simple Django syntax. It says: {'Message': 'Request data is in Bad Format.'} Please help how can I add Header and Body commands with this API call from Django? -
How to convert unicode character to decimal in Django
Here let us consider my unit_price to be 1000 my views.py as class StockView(View): def get(self, request, id=None): stock_movement = StockMovements.objects.filter(client=client) item_unit_price = request.GET.get('unit_price','') if item_unit_price: if '=' in item_unit_price: unit_price = item_unit_price.split('=')[1].strip() price = Decimal(unit_price) stock_movement = stock_movement.filter(item__unit_price=price) if '>' in item_unit_price: unit_price = item_unit_price.split('>')[1].strip() price = Decimal(unit_price) stock_movement = stock_movement.filter(item__unit_price__gte=price) def autocomplete_items(request): client = request.user.client q = request.GET.get('term') job_items = JobItems.objects.filter(client_id=client) products = job_items.filter(Q(item_name__icontains=q)|Q(unit_price__gte=q),is_deleted=False) return HttpResponse(json.dumps(res[:15])) Here is my template.html <div class="form-search contacts-search pull-right {% if searchapplied %}search-applied{% endif %}"> <form method="GET"> <div {% if search %} class="input-append"{% endif %}> <input type="text" class="search-query" name="unit_price" id="item_unit_price" placeholder="Unit Price" class="ui-autocomplete-input" autocomplete="off"><span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span> <button class="btn btn-danger" type="submit" style="margin-bottom: 8px;"> <i class="fa fa-search" aria-hidden="true"></i> </button> </div> </form> here is my script for template.html $('#item_unit_price').autocomplete({ source: function(request, response) { $.ajax({ url: "/autocomplete_items/?flag=True", data: { term: request.term, unique: true, }, dataType: 'json', success: function(json_data) { var chain_names = []; for(i=0; i<json_data.length; i++) { chain = json_data[i]; chain.value = json_data[i].label; chain.label = json_data[i].label; chain_names.push(chain); } response(chain_names); } }) }, minLength: 1, select: function(event, ui) { $( "#item_unit_price" ).val( ui.item.value);; } }); here is my models.py class StockMovements(models.Model): item = models.ForeignKey(JobItems, related_name="stock_movements") class JobItems(models.Model): unit_price = models.DecimalField(null=True, max_digits=10, decimal_places=2, default=0.00, verbose_name='Retail price') Now if … -
Django How to bring data into url from DB?
Models.py from django.db import models # Create your models here. class reviewData(models.Model): building_name = models.CharField(max_length=50) review_content = models.TextField() star_num = models.FloatField() class buildingData(models.Model): building_name = models.CharField(max_length=50) building_loc = models.CharField(max_length=50) building_call = models.CharField(max_length=20) views.py # Create your views here. from django.shortcuts import render from rest_framework.response import Response from .models import reviewData from .models import buildingData from rest_framework.views import APIView from .serializers import ReviewSerializer class BuildingInfoAPI(APIView): def get(request): queryset = buildingData.objects.all() serializer = ReviewSerializer(queryset, many=True) return Response(serializer.data) class ReviewListAPI(APIView): def get(request): queryset = reviewData.objects.all() serializer = ReviewSerializer(queryset, many=True) return Response(serializer.data) urls.py from django.contrib import admin from django.urls import path from crawling_data.views import ReviewListAPI from crawling_data.views import BuildingInfoAPI urlpatterns = [ path('admin/', admin.site.urls), path('api/buildingdata/', BuildingInfoAPI.as_view()), #path('api/buildingdata/(I want to put building name here)', ReviewListAPI.as_view()) ] I am making review api. I want to use building name as url path to bring reviews for specific buildings For example, there are a, b, c, d, e reviews a, b, c reviews are for aaabuilding d, e reviews are for aaabuilding api/buildingdata/aaabuilding (only shows aaabuilding review) api/buildingdata/xxxbuilding (only shows xxxbuilding review) I've searched some dynamic url posts, but they were not that i want. Is there any way to bring building name into url from db? -
How to use Curl post request for Django
I am new to Django. My application post request to/from zabbix and doesnt have authentication mechanism and I am not using REST framework. My setup is Django+Nginx+Gunicorn_Whitenoise+Certbot for SSL on RHEL box. I have a requirement to post data using curl command. I tried using curl with -X POST -G options but getting error. Most of the google search says to use REST ful framework. Please advise on best solution to use curl post request for existing Django application with minimun modifications. -
Django server not opening with 0.0.0.0:8000
I have a AWS server runs on Nginx and which hosts a React application working fine on server. Now I want a Django app for restframework to be available on the same server. Iam following the Document and uploaded the Django app on the server and try to run the app by trying python3 manage.py runserver 0.0.0.0:8080. There is no error but I cannot access my ip with http://server_domain_or_IP:8080. Please help where am I going wrong? -
How to run to bot on DigitalOcean
I have bot in my Django project and I deployed my project to DigitalOcean my site working but I don't know how do run to bot I tried write to gunicorn but it is not working. How to write to gunicorn python manage.py bot enter image description here -
Number of Tags used in post which were commented by user
I am building a simple Blog App and I am trying to implement a feature. In which, If a user commented on a post with post tags - tag1, tag2. And I will retrieve the Tags of which user commented on post And i am trying to count Number of times a user commented on a post with same tag Like I am trying to show :- Tag Name Number of times used tag1 16 Times tag2 10 Times tag3 8 Times This table is showing :- User commented on a post with the tag which was used in previous post. For Example :- A new user named "user_1" commented on a Post with tags tag5, tag6, tag8 then A query will show that user_1 has commented on post tags 1 times in tag5 , 1 time in tag6 and 1 time in tag8. And I will do the rest later. models.py class BlogPost(models.Model): user = models.ForeinKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=30) tags = TaggableManager() class Comment(models.Model): comment_by = models.ForeignKey(User, on_delete=models.CASCADE) on_post = models.ForeignKey(BlogPost, on_delete=models.CASCADE) views.py def examplePage(request): query = Tag.objects.filter(blogpost__user=request.user) context = {'query': query} return render(request, 'examplePage.html', context) This view is showing tags which are used in post which were … -
Why DRF suggest to override HTTP methods in serializers?
Since all the HTTP methods are implemented in Viewsets, isn't it make sense to override them in child Viewsets? why Django rest framework has given a lot of examples of overriding these methods in serializers? Is there any trade-off overriding these methods in serializers vs viewsets? -
Why Getting (user.models.DoesNotExist: CustomUser matching query does not exist.)?
I have create two models CustomUser inheriting AbstractUser and UserProfile, and there is OneToOne relation between them. then i run the following command:- python manage.py makemigrations python manage.py migrate python manage.py createsuperuser When i run the command for createsuperuser, i got error as bellow:-(model are posted in the end..) PS C:\Users\akcai\OneDrive\Desktop\deep_Stuffs\git_cloned\PollingApplication> python manage.py createsuperuser Email: admin@gmail.com Name: admin Username: admin Password: Password (again): The password is too similar to the username. This password is too short. It must contain at least 8 characters. This password is too common. Bypass password validation and create user anyway? [y/N]: y profile create too.. Traceback (most recent call last): File "C:\Users\akcai\OneDrive\Desktop\deep_Stuffs\git_cloned\PollingApplication\manage.py", line 22, in <module> main() File "C:\Users\akcai\OneDrive\Desktop\deep_Stuffs\git_cloned\PollingApplication\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line utility.execute() File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 79, in execute return super().execute(*args, **options) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 398, in execute output = self.handle(*args, **options) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 189, in handle self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\models.py", line 163, in create_superuser return self._create_user(username, email, password, **extra_fields) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\models.py", line 146, in _create_user user.save(using=self._db) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\base_user.py", line 67, in save super().save(*args, **kwargs) File "C:\Users\akcai\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\base.py", line 726, in save self.save_base(using=using, … -
Is there a query set to compare id of two different model and if id matched i wanna auto fill the html form?
I want to auto-fill my one form when I enter Id then data related to that id is auto fill-in HTML form like Name, Address, Gender, Email, Images, etc. I am not seeing any errors but the code doesn't work as expected Both salary payment model and staff registration model are of Different apps When I register a staff his/her id and another detail are saved in the database with their unique Id and when I give staff his/her salary I want to auto-fill the HTML form when I enter the id of the particular staff. If both staff registration id is equal to the id we have typed in salary payment form matched then data related to that id is autofill in HTML form where user can see #This is my salary payment model:- class SalaryPayment(models.Model): Staff_id = models.UUIDField(primary_key=True) Staff_Image = models.ImageField(null = True,blank = True) Staff_Name = models.CharField(max_length=256) Staff_Address = models.CharField(max_length=256) Staff_Phone = models.CharField(max_length=15) Staff_Profession = models.CharField(max_length=256) Gender = models.CharField(max_length=15) Citizen_Ship_No = models.CharField(max_length=150) Staff_Basic_Salary = models.DecimalField(max_digits=10,decimal_places=2) Staff_Extra_Income = models.DecimalField(max_digits=10,decimal_places=2) Total = models.DecimalField(max_digits=20,decimal_places=2,default=0.00) slug = models.SlugField(unique=True,allow_unicode=True) #This is my Staff registration model:- class StaffRegistration(models.Model): Staff_id = models.UUIDField(primary_key=True,default=uuid.uuid4) Staff_Image = models.ImageField(blank = True,null = True) Name = models.CharField(max_length=250,null=False) Address = … -
Google recaptcha v2 not getting a response django
when I go to this site: https://www.google.com/recaptcha/api/siteverify, it show this on my screen as shown below, is there something wrong with my code? Do I need I need to change my 'g-recaptcha-response'? I already added both the site key and the secret key in my settings.py "success": false, "error-codes": [ "missing-input-secret" ] } 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) ''' Begin reCAPTCHA validation ''' recaptcha_response = request.POST.get('g-recaptcha-response') url = 'https://www.google.com/recaptcha/api/siteverify' values = { 'secret': 'aaaaaaaaaaaaaaaaaaaaaaa', 'response': recaptcha_response } data = urllib.parse.urlencode(values).encode() req = urllib.request.Request(url, data=data) response = urllib.request.urlopen(req) result = json.loads(response.read().decode()) ''' End reCAPTCHA validation ''' if user is not None and user.is_admin: request.session['userid'] = user.pk # retrieve the user id login(request, user) messages.success(request, "You have login to the admin page") return redirect('home') if user is not None and user.is_logistic: # # authenticated if user is a logistic request.session['userid'] = user.pk # retrieve the user id login(request, user) messages.success(request, "You have login to the logistic page") return redirect('logistic') # redirect the user to the logistic page if user is not None and user.is_customer: # authenticated if user is a customer service request.session['userid'] = user.pk # retrieve the user … -
Images are not loading from aws S3
I am doing a Django project. I have hosted my static files on AWS S3.It has been successfully uploaded to it. But,the images are not loading when I run the server. When I inspect the image field it shows: https://django-ecommerce-files.s3.amazonaws.com/images/logo.png%22%20id=%22image%22%20style=%22width:%2040px;%20height:40px%22%3E When I double clicked it. It shows this error: <Error> <Code>AccessDenied</Code> <Message>Access Denied</Message> <RequestId>07PX6KHYASHT3008</RequestId> <HostId>pJCxChq1JHlw/GL0Zy/W+PvX1TevOf/C60Huyidi8+0GMAs8geYlXSrEgo6m9vllL0PouTn6NAA= </HostId> </Error> -
How to tokenize/encrypt fields in django?
In the following screenshot the actual password look like Password123 but when I run user = User.objects.create(...) user.set_password('Password123') user.save() #then in login I have to run from django.contrib.auth import authenticate user = authenticate(username=username, password=password) user.... However, Django will automatically set it like this handle the necroption or the tokenization whatever you name this, and the parsing in authenticate function. The question: I want to do the same for an integer field in order to prevent even the admin from seeing that field so it will be a secret fied only the user can see. -
Django Model Data dynamic with column name and value
During django create new records in dynamic way got error, ID is expection number but got 'OrderNo= "Order No", OrderSuffix= "Order Suffix", Reference= "Reference", ItemCode= "Item Code", QtyOrdered= "Qty Ordered", QtyShipped= "Qty Shipped", Warehouse= "Warehouse", DispatchDate= "Dispatch Date", TrackingNo= "Tracking No", CarrierCode= "Carrier Code"' But if i put this string like data = quatius_shipment(OrderNo= "Order No", OrderSuffix= "Order Suffix", Reference= "Reference", ItemCode= "Item Code", QtyOrdered= "Qty Ordered", QtyShipped= "Qty Shipped", Warehouse= "Warehouse", DispatchDate= "Dispatch Date", TrackingNo= "Tracking No", CarrierCode= "Carrier Code") for row in table: ind = 0 rowdata = '' for col in config['header_columns']: rowdata += col['title'] + '= "' + row[ind] + '"' + ', ' ind = ind + 1 rowdata = rowdata[:-2] #return HttpResponse(rowdata) data = quatius_shipment(rowdata) data.save(using="integration") That means created string variable if i put directly for make it dynamic its showing "ID" expected a number but the string if i put its totally working fine. May anyone help me.Thanks in Advance. -
Django Template Inheritance and For Loop
I have two HTML file app/blog.html <h1>TEST</h1> {% for blog in blogs %} <h1>{{ blog.title }}</h1> <p>{{ blog.author }}</p> {% endfor %} app2/mainpage.html {% extends 'base.html' %} {% load static %} {% block content %} {% include 'app/blog.html' %} //it only shows TEST with heading 1, but each blog inside for loop isnt showing {% endblock content %} I tried to create seperate url for blog.html, and it works fine (each blog inside for loop is rendered) Is it possible to show each item inside for loop using include? How can i do that? Thanks. -
ModelForm not saving to the database
I currently have a ModelForm in a Django-Python web app that allows users to edit settings for financial documents. The form currently does not save into the database for some reason. I think that this is due to the validity of the form/model. Is it because some BooleanFields are True/False or is it something to do with the way the form is imported. I tried to check if the fact that I am using 2 forms for the same model is causing a problem but I can't seem to see an error here. Please see the below code: Views.py: def viewSettings(request, settings_pk): setting = get_object_or_404(SettingsClass, pk=settings_pk) if request.method == 'GET': form = SettingUpdateForm(instance=setting) return render(request, 'main/viewSettings.html', {'setting': setting, 'form':form}) else: form = SettingUpdateForm(request.POST, instance=setting) if form.is_valid(): form.save() return redirect('settingsHome') return render(request, 'main/viewSettings.html', {'setting': setting, 'form':form}) Forms.py: class SettingsForm(ModelForm): class Meta: model = SettingsClass fields = ('Complex','Trial_balance_Year_to_date' , 'Trial_balance_Monthly' , 'Income_Statement_Year_to_date' , 'Income_Statement_Monthly' , 'Age_Analysis' , 'Balance_Sheet' , 'Repair_and_Maintenance_General_Ledger' , 'Major_capital_Items_General_Ledger') class SettingUpdateForm(ModelForm): class Meta: model = SettingsClass fields = '__all__' Models.py: class SettingsClass(models.Model): Complex = models.CharField(choices=complex_list , max_length = 22 ,default='1' , unique=True) #Trial Balance Year To Date Trial_balance_Year_to_date= models.BooleanField(default = False) tbytd_Include_opening_balances=models.BooleanField(default = False) tbytd_Only_use_main_accounts=models.BooleanField(default = False) tbytd_Print_null_values=models.BooleanField(default = … -
SQL database connections over 800,000?
Yes, I know. Seemingly impossible for a 2GB RAM server, right? show status like 'Conn%'; Returns: (constantly climbing) Connections: 809662 But I am using a Django web app, which normally closes threads after the page is loaded. Not using any manual queries. Plus, I have my max_connections set to 300, so how could it even be this high? Am I misunderstanding something? How do I see current connection count, if not this? Users hit an API endpoint through a refresh widget once every 45 seconds, but the endpoint is cached for 40 seconds... so most of those requests should not be doing DB queries. I have confirmed the cache is working too, which is done through memcached. -
Importing Django seriliazer fields into another seriliazer feilds
I am currently working on a website for my students where it will help them to book some items on the classroom. I am already done with the booking logic and form so no two students are allowed to book the same item at the same time. I would like to create a table for them where it shows the item name and the status of the item based on the current time, and the current owner of the item at the momment. The thing is I have three models. The first one is Details where it have all information about the items, the other model is Item which simply list the Item name, and last is the Booking model which I use for the booking form and logic, this model will create a list of all bookings made by the students. class Details(models.Model): item_name = models.CharField(max_length=50, editable=False) item_id= models.IntegerField(editable=False) Publish_date = models.DateField() auther = models.CharField(max_length=20) def __str__(self): return self.item_name class Items(models.Model): ITEMS_CATEGORIES=( ('item-1', 'item-1'), ('item-2', 'item-2'), ('item-3', 'item-3'), ('item-4', 'item-4'), ('item-5', 'item-5'), ) category = models.CharField(max_length=5, choices=ITEM_CATEGORIES) def __str__(self): return self.category class Booking(models.Model): user = models.CharField(max_length=50, editable=False) note = models.CharField(max_length=300, default='SOMESTRING') item = models.ForeignKey(Subsystem, on_delete=models.CASCADE) check_in = models.DateTimeField() check_out … -
Problem including an external JQuery into Django template
The template below has no problems if I run it inside the same html template. But if I put the JQuery code in a country_dropdown.js external file inside the static folder, and I include it like that: <script src="{% static 'js/countries.js' %}"></script> then the following: url: "{% url 'get-province' %}", will not work. It seems that the {% tags are not recognized inside external js files, even if they should. In fact the requested is rendered this way: Request URL: http://127.0.0.1:8000/countries/%7B%25%20url%20'get-province'%20%25%7D Obviously the %7B means { and the %25 means %. Therefore template tags are not properly recognized outside the template. But, since I will use the same functionality and the same drop-down list in several places, it would be a very good practice to put the JQuery in an external file and include it when I need it instead of duplicating it in each template where it is needed. How could I include the external JQuery without problems? I have included the complete template here. {% extends 'base.html' %} {% load i18n %} {% load static %} {% block content %} <form class="" action="" method="post"> {% csrf_token %} {% for error in errors %} <div class="alert alert-danger mb-4" role="alert"> …