Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Hide Django's staticfiles from GitHub stats
To understand what I'm talking about, I call GitHub stat this line: I have my Django project on GitHub repository and, I use Heroku to deploy this project. To deploy my project to Heroku, I need first to run python manage.py collectstatic that will generate a lot of CSS and JS like on screenshot above. So, I want to hide this folder not ignore, because Heroku needs it to work properly. -
Testing non-abstract method of an abstract class in python
I have an issue similar to the one mentioned here. However, I believe that my classes slightly differ. Here is what i have: A.py: from [...] import B class A(ABC): def __init__(self): self.b = B() def get_data(self): for-loop: x = self.b.methodA(x) @abstractmethod def update(self): pass B.py: class B: def methodA(self, x): # Do something here I am trying to test class A's get_data() without using any of its subclass(es). In my test method, I am patching methodA() as I do not want to test the api call. In order for me to test a non abstract method in an abstract class without the instantiation of a subclass, i used the following code: abstract_concreter.py: def concreter(A): if "__abstractmethods__" not in A.__dict__: return A new_dict = A.__dict__.copy() for abstractmethod in A.__abstractmethods__: new_dict[abstractmethod] = lambda x, *args, **kwargs: (x, args, kwargs) return type('dummy_concrete_{}'.format(A.__name__), (A,), new_dict) My test method looks like this: @patch('<path>.A.B.methodA', spec=True) def test_get_data(self, mock_fn): concreter(A).get_data(self, x=123) print(mock_fn) # <MagicMock name='methodA' spec='function' id='74741552'> mock_fn.assert_called_with(123) Yet i get the following error: AssertionError: Expected call: methodA(123) Not called I am still pretty new to unittest and the whole patch/mocking usage, I believe I am missing something or I am not writing it in the … -
What's the best approach to have a second authentication in Django Rest Framework?
Well, I have a django application one single user account can have more than one profile. I made a custom authentication where users can log in with e-mail and password to get authenticated via Jason Web Token. After that, with this Jason Web Token (account related) they can request another extended JWT just sending the ID of the profile in the request. I made a custom middleware to get the token in every request and succesfully get the user and the profile and insert it to the request object to access the wanted data from any other point, for example views and permissions. What's the best way to get the second call asking for a password when I want to switch between profiles? (just same behaviour of the first request) In other words, What's the best approach to have a second authentication system for my profiles (only available when the account is authenticated? The options I'm considering so far: 1) A second custom authentication backend. 2) A pincode in the profiles model (barely secure) -
What is SilentPrint ahead of main url?
Currently I am not able to load my website page in firefox because of silentprint preceding ahead of main url. My website working perfectly in chrome browser but in firefox only I am getting error because of silentprint. .js file var manaulPrintURL = "SilentPrint:"+ printURL; $(this).attr('href', manaulPrintURL); document.getElementById(this.id).click(); After loading website in firefox my url become like "silentprint:http://192.168.1.192:8010/test/419/" & getting error saying as below screenshot. Why I am getting above kind of problem only when using firefox browser & what will be solution of it. Thanks. -
django runserver, skiping/caching? requests when multiple executed at the same time
When running django-admin runserver and executing multiple PATCH requests at the same time, I see logs for all but only one is executed when I debug. The problem disappeared when using django-admin runserver --nothreading. I am using Pycharm debugger, maybe because runserver is by default using multithreading, so when 2 requests come at the same time a second thread is created which is not seen/debugged by Pycharm. So thats why I cannot debug it but I see logs. But the second thing is that only one request is successful with PATCH update, I know django-admin runserver is not aim for production but is there any data race condition ? I have tried to use django.db.transaction.atomic but it didn't make any change ? My initial conclusion is that runserver is not thread save if we consider database updates, so if testing multiple updating requests --nothreading flag should be used. I would appreciate any help/explanation here. Best, Igor P.S. I haven;t any code as I think it doesn't help here in any way: -
how to load css file in html file already extends another html file (base.html) in django
I'm new to django, so i get difficulty in dealing with django template in relation to adding css file into django template.My code is as follows: base.html {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="{% static 'portfolio/main.css' %}"> {% if title%} <title>Django Portfolio - {{title}}</title> {% else %} <title>Django Portfolio</title> {% endif %} </head> <body> <div class="topnav"> <a class="active" href="{% url 'portfolio-home' %}">Home</a> <a href="{% url 'portfolio-page' %}">Portfolio</a> <a href="{% url 'portfolio-about' %}">About</a> <a href="#blog">Blog</a> <a href="#account">Account</a> </div> <div class="container"> {% block content %} {% endblock content %} </div> </body> </html> This is my base.html file in which all my other html files inherit it.It works perfectly fine.Note:-I create the static file inside django app and put two static files; main.css and home.css for now. But i want to design homepage, and i av done this with the file known as home.html and use the home.css in static file.My code is as follows: home.html {% extends 'portfolio/base.html' %} {% load static %} {% block content %} <link rel="stylesheet" type="text/css" href=" {% static 'portfolio/home.css' %}" /> <h1>My homepage</h1> {% endblock content %} The problem is, the line <link … -
create Field with specific persimmons in django
i want to add a field in my module to give the user some persimmons like is_superuser field but with customize persimmons how can i do this ? class CustomUser(AbstractUser): username = models.CharField(max_length=100,unique=True) email = models.EmailField(_('email address'), unique=True) image = models.ImageField(default='default.jpg', upload_to='profile_pics ') date_joined = models.DateTimeField(_('date joined'),default=timezone.now) is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email'] objects = CustomUserManager() -
Django User model: When using set_password, it seems model is being saved before pass validation
Sometimes i want to set the password programitically. So i try the following https://docs.djangoproject.com/en/2.2/topics/auth/default/#changing-passwords You can also change a password programmatically, using set_password(): >>> from django.contrib.auth.models import User >>> u = User.objects.get(username='john') >>> u.set_password('new pass') >>> u.save() I wanted to see how things are implemented in save() when we run >>> u.save() Bsically I am trying to undestand the save() method used in AbstractBaseUser # ./.venv/lib/python3.7/site-packages/django/contrib/auth/base_user.py class AbstractBaseUser(models.Model): password = models.CharField(_('password'), max_length=128) ........ # Stores the raw password if set_password() is called so that it can # be passed to password_changed() after the model is saved. _password = None def save(self, *args, **kwargs): super().save(*args, **kwargs) if self._password is not None: password_validation.password_changed(self._password, self) self._password = None ........ def set_password(self, raw_password): self.password = make_password(raw_password) self._password = raw_password Here in def save(self, *args, **kwargs): super().save(*args, **kwargs) will save the password set by set_password before the next lines password_validation.password_changed which validate the password So what is the point in saving the password first and then checking. Because its gone into database. -
converting html to pdf using pisa
I am trying to generate a PDF using an already existing DJANGO HTML template. I am passing context data dynamically into the template then trying to convert it to HTML. I however keep on running into this File "C:\Users\EliteBook\Desktop\Virtual_Environment\app\lib\site-packages\reportlab\platypus\tables.py", line 265, in init raise ValueError("%s data error - %d rows in data but %d in row heights" % (self.identity(),nrows, len(rowHeights))) ValueError: with cell(0,0) containing ' size=x' data error - 16 rows in data but 15 in row heights when this line of code is executed... pdf = pisa.pisaDocument(BytesIO(html.encode("cp1252", 'ignore')), result) I have looked into PISA and REPORTLAB forums but do not seem to find a suitable solution. Below is the code that attempts to generate the PDF def make_pdf(student): entry = Transaction.objects.filter(student=student) credits = entry.filter(t_type='C') debits = entry.filter(t_type='D') c_count = entry.filter(t_type='C').count() d_count = entry.filter(t_type='D').count() e_count = entry.count() name = student.name context = { 'entries':entry, 'student':student, 'credits' : credits, 'debits':debits, 'c_count': c_count, 'd_count': d_count, 'e_count': e_count, 'name':name } return render_to_pdf('payment/statement.html', context) The return to render is defined in different file as thus: from io import BytesIO from django.http import HttpResponse from django.template.loader import get_template from xhtml2pdf import pisa def render_to_pdf(template_src, context_dict={}): template = get_template(template_src) html = template.render(context_dict) result = BytesIO() pdf … -
I want to use django-hitcount to count hits on my Class based view
I want to use django-hitcount to count the hits to my Class based views. I was following this documentation https://django-hitcount.readthedocs.io/en/latest/ and it's not clear to me how I could achieve that. I have gone as far as using the HitCountMixin like so class HomeView(TemplateView, HitCountMixin): template_name = 'home/index.html' def get(self, request): sections = Section.objects.all() return render(request, self.template_name, {'sections': sections }) I have gone through every installation step, but the hits are not appearing on the admin interface. -
How to pass a model to a base.html that all templates extend from base.html
I have a Django project which I have a base.html that all templates inheritance from that. Then I include a category.html file in base.html which is just my navigation bar. So I have a model named Category and I want to pass this model to category.html to show my categories. I don't know how to do that? base.html: <!DOCTYPE html> {% load static %} <html lang="en" style="height: 100%;"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>{% block title %}{% endblock %}</title> <!-- Google Fonts --> {% comment %} <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <!-- Bootstrap core CSS --> {% endcomment %} <link href="{% static 'fontawesome/css/all.css' %}" rel="stylesheet"> <!--load all styles --> <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"> <!-- Material Design Bootstrap --> <link href="{% static 'css/mdb.min.css' %}" rel="stylesheet"> <!-- Your custom styles (optional) --> <link href="{% static 'css/style.min.css' %}" rel="stylesheet"> <!-- Mega menu style --> <link href="{% static 'css/bs4megamenu.css' %}" rel="stylesheet"> {% block extra_head %} {% endblock %} {% block slideshow %} {% endblock slideshow %} </head> <body> <!-- Category Navbar --> {% include 'category_navbar.html' %} <!-- Category Navbar --> <!-- Body Content --> {% block content %}{% endblock %} <!-- Body Content --> <!-- Footer and scripts--> … -
How to set logout url in django-registration?
Log out works okay, but I can't set redirect logout url using django-registration. In html: <h3> <a style="color:white" href="{%url 'logout' %}">"Logout"</a></h3> In settings.py: LOGOUT_REDIRECT_URL = "accounts/logout" I can access login page using accounts/login in browser, but it doesn't work for accounts/logout(Page not found.,but this page is in registration folder). -
'UserUpdateForm' object has no attribute 'field'
Error during template rendering In template C:\Users\jaimin patel\PycharmProjects\WEBPROJECT\venv\lib\site-packages\crispy_forms\templates\bootstrap4\field.html, error at line 6 'UserUpdateForm' object has no attribute 'field' from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Profile class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] class UserUpdateForm(forms.ModelForm): email = forms.EmailField() class Meta: model = User fields = ['username','email'] class ProfileUpdateForm(forms.ModelForm): class Meta: model = Profile fields = ['image'] -
MultiValueDictKeyError at /admin/criminals 'gender'
I sufering from the problem with my code, whenever i entered my data into the database and then at time when i click submit it will through an error Multyvaluekeyerror. i change my form value so many times but nothing is working. Please help me out this.....it very be thankfull. MultiValueDictKeyError at /admin/criminals 'gender' Request Method: POST Request URL: http://127.0.0.1:8000/admin/criminals Django Version: 2.2.4 Exception Type: MultiValueDictKeyError Exception Value: 'gender' Exception Location: C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\datastructures.py in __getitem__, line 80 Python Executable: C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\python.exe Python Version: 3.7.4 Python Path: ['D:\\django project\\gadmin3', 'C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip', 'C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32', 'C:\\Users\\lenovo\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Users\\lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages'] Server time: Mon, 7 Oct 2019 04:35:54 +0000 MAIN FORM CODE:- <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12">Gender</label> <div class="col-md-6 col-sm-6 col-xs-12"> <div name="gender" id="" class="btn-group" data-toggle="buttons"> <label class="btn btn-default" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default"> <input type="radio" name="" value="male" data-parsley- multiple="gender"> &nbsp; Male &nbsp; </label> <label class="btn btn-primary" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default"> <input type="radio" name="" value="female" data-parsley- multiple="gender"> Female </label> </div> </div> </div> VIEW SIDE CODE:- def criminals(request): if request.method=="POST": cn = request.POST['crname'] ccrime = request.POST['crime'] cage = request.POST['age'] cheight=request.POST['height'] cbody = request.POST['bodymark'] crgen = request.POST['gender'] s= Criminals() s.mname=cn s.mcrime=ccrime s.mage=cage s.image = request.FILES['photo'] s.mheight=cheight s.mbody=cbody s.mgender=crgen s.save() messages.success(request,"Criminal Added Successfully.") return render(request,'criminal.html') else: return render(request,'criminal.html') -
How to have custom success url in update view based on different submit buttons in django template?
I have a CustomUser model and a partner model and a student model both having OneToOne relatioship to CustomUser as below: class CustomUser(AbstractUser): username = None email = EmailField(verbose_name='email address', max_length=255, unique=True, ) first_name = CharField(verbose_name='First Name', max_length=30, null=True, ) middle_name = CharField(verbose_name='Middle Name', max_length=30, null=True, blank=True, ) last_name = CharField(verbose_name='Last Name', max_length=30, null=True, ) phone_number = CharField(verbose_name='Phone Number', max_length=30, null=True, ) is_partner = BooleanField(default=False, ) is_student = BooleanField(default=False, ) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email class Partner(Model): user = OneToOneField(CustomUser, on_delete=CASCADE, related_name="partner") class Student(Model): user = OneToOneField(CustomUser, on_delete=CASCADE, related_name='student') I have a view in which I want to update first_name, last_name, middle_name, and phone_number of the user. This is a simple update view. But I want to put two submit buttons, in edge case, both of which might be available in the page: <form method="post" novalidate> {% csrf_token %} {% include 'includes/accounts/user_name_and_phone_update_view_form.html' with form=form %} {% if user.is_student %} <button type="submit" name="student" id="student">Continue to Student Profile</button> {% endif %} {% if user.is_partner %} <button type="submit" name="partner" id="partner">Continue to Partner Profile</button> {% endif %} </form> I need to customize my view as below(this is pseduo code): @method_decorator([login_required, ], name='dispatch') class UserNameAndPhoneUpdateView(UpdateView): model = … -
After apply lestsencrypt , my nginx server is dead
I deployed django project, with nginx, uwsgi. but after apply ssl(letsencrypt), it works and my server is getting slowly and finally have no react. Is it related with applying ssl?? Please comment even if it is little hint. I totally panic now... -
what is the flow of django website.... what views, templates, models and forms does actually
I am new to django web programming and struggling from 1 month to get the hang of view + models + forms + templates... and i just cant get it fully. please can anyone explain it in simple and to the point. thanks for your help. According to me if i need to show a login page I have 2 options. 1 to use build-in UserCreadentialForms way which is in all the youtube tutorials. 2 is to use custom built. i have successfully used 1 way and now tring to use custom built forms. for this, i goes to models and create a model of my choice (given below) then goes to run that migrate commands to actually create them in database... now tell me how to show/ fillout/ render those fields in the templates. (i am currently using admin url to register/fill out the data in fields and display them on template) base template <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body> {% if title %} <title>Django Blog - {{ title }}</title> {% else %} <title>Django Blog</title> {% endif %} <h1>I am base Template</h1> … -
jquery from base.html not working in other templates in django
I am working on a django application. With templates in django I created multiple pages with one base template. pages like index.html, about.html and contact.html inherit the code from base.html. Inside the base.html template is code for a navbar. base.html {% load staticfiles %} <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <!-- bootstrap --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <!-- fonts --> <link href="https://fonts.googleapis.com/css?family=Anton|Open+Sans&display=swap" rel="stylesheet"> <!-- base.css --> <link rel="stylesheet" href="{% static 'css/base.css' %}"> <!-- base.js --> <script src="{% static 'js/base.js' %}"></script> <title>{% block title %}base{% endblock %}</title> {% block header %}{% endblock %} </head> <body> {% block content %} {% endblock content %} <!-- navbar --> <nav class="navbar fixed-top navbar-expand-lg"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link hover_effect" href="{% url 'home' %}">Home</a> </li> <li class="nav-item active"> <a class="nav-link hover_effect" href="{% url 'about' %}">About Us</a> </li> <li class="nav-item"> <a class="nav-link hover_effect" href="{% url 'contact_us' %}">Contact Us</a> </li> </ul> </div> </nav> </body> </html> When viewed in a browser the navbar by default has no background color, but when scrolled down, background-color … -
A lot of JS and CSS after collectstatic Django
In my GitHub repo I have created my Django project. To deploy my app to Heroku, I need first run python manage.py collectstatic and push this staticfile folder that collectstatic command has created to heroku git. So, this staticfile folder contain a lot of falsy statistics e.g 48.6% of CSS (what?) that I don't want to show in my GitHub repo. I have thought to hide it in .gitignore file, but, what if I want to push something else? I will have to unignore this folder, and then add my changes. Is there easier or better way to do this? -
A base64 encoding is returning None from the .bash_profile where I save it as an Environment variable
I saved a base64 encoding as as an environment variable in .bash_profile .bash_profile export ENCODED_JSON="b'Aewe323'" doing the following in a python script returns None import os ENCODED_JSON = os.environ.get('ENCODED_JSON') print(ENCODED_JSON) -
What does it mean of '|' in django template?
Currently I am developing website from another old website & I have faced below code which I am not able to understand properly. I am calling javascript from django template with user permission. test.html file <script type="text/javascript"> (function(){ var data = {'type' : '{{type}}','permissions':{{permissions|safe}} }; var testJS =testInit(data); })(); </script> What does it mean of '|' in {{permissions|safe}}. -
How can I use fingerprints collected from a portable fingerprint sensor for development?
For a standalone web-based program, I need to implement biometric verification. Like, I want to store fingerprints in DB and use it at the time of verification. -
Dictionary 0 key value is not picked up when the values enter through the loop
At runtime it does't access value at index[0] and give error of 'avg' not defined How do i fix it. It require two decimal value but it give only one decimal value. CODE BELOW: n = int(input()) student_marks = {} for i in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores print(scores) print(student_marks) query_name = input() if query_name == name: print(query_name) avg=0 avg=sum(scores)/3 print(avg) OUTPUT: 4 dd 3 34 2 2 [3.0, 34.0, 2.0, 2.0] {'dd': [3.0, 34.0, 2.0, 2.0]} g 3 4 5 6 [3.0, 4.0, 5.0, 6.0] {'dd': [3.0, 34.0, 2.0, 2.0], 'g': [3.0, 4.0, 5.0, 6.0]} d 3 4 534 34 [3.0, 4.0, 534.0, 34.0] {'dd': [3.0, 34.0, 2.0, 2.0], 'g': [3.0, 4.0, 5.0, 6.0], 'd': [3.0, 4.0, 534.0, 34.0]} e 3 4 4 4 [3.0, 4.0, 4.0, 4.0] {'dd': [3.0, 34.0, 2.0, 2.0], 'g': [3.0, 4.0, 5.0, 6.0], 'd': [3.0, 4.0, 534.0, 34.0], 'e': [3.0, 4.0, 4.0, 4.0]} dd Traceback (most recent call last): File "C:/Users/Priya/Desktop/1.py", line 15, in <module> print(avg) NameError: name 'avg' is not defined -
how to connect front-end and djangop api with valid token using AzureAD
I have this front-end using react. In this react application, I added Azure Oauth2 ( i used react-adal ) sign-in. I want to pass the token from the front-end to django-api so whenever i call the api, I have this valid token. -
How to save the CSV file in variable
I'm new to Django and Python. I'm trying to compare two CSV files and make a new file as a result (how much both files are different from each other) in my views.py. First, I get those files and set them into a variable, to make sure that the user can select and compare any file with any name. But I got this error. FileNotFoundError at /compare [Errno 2] No such file or directory: 'fine_name.csv' what I'm expecting is, when the user selects two files and hit on the compare button, they got a new updated CSV file 'update.csv'. Here is my code views.py from django.shortcuts import render from django.http import HttpResponse def comp(request): if request.method == 'POST': file1 = request.POST.get('file1', '') file2 = request.POST.get('file2','') with open(file1, 'r') as t1, open(file2, 'r') as t2: fileone = t1.readlines() filetwo = t2.readlines() with open('update.csv', 'w') as outFile: for line in filetwo: if line not in fileone: outFile.write(line) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="update.csv"' return response return render(request,'compare.html') compare.html {% extends 'base.html' %} {% block title %}Comparision{% endblock %} {% block content %} <div class="container"> <div class="row justify-content-md-center"> <div class="col-md-6"> <form method="POST" action="">{% csrf_token %} <h1 class="mb-3 display-4 text-light">Comparision</h1> <input type="file" id="file1" …