Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why does Django give a warning about unapplied migrations and how to fix it?
I started learning Django and i find a warning message: " You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them.". What is the reason behind this warnings Just want to know this -
Django - get value from html select options that have been generated in a loop
i have a html page where i have set up a loop to list band names on a page. I also have a select option box so users can rate bands they have seen. Problem is because each of the select options is generated in my loop i don't know how i'm going to access each rating back in my views.py file. Please help? html code {% for band in thursday_apex %} <li> {{ band.band_name }} {{ }} <select name="thursday_apex"> <option value="0">Didn't watch</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </li> {% endfor %} -
How do I add the project title to the project_details url's (slug) on this django project
I've been stuck trying to add the project title to the project_details urls (slug). The issue is, I would rather achieve this without changing the models.py as this would create complications with the db... Is there a way to achieve this with just changes to the veiws.py, urls.py and the link tag? Here is my code, any help is much appreciated... from django.shortcuts import render from django.views.generic import TemplateView from django.shortcuts import get_object_or_404 from .models import ProjectPost from django.db.models import Q from django.db.models import F from django.core.paginator import Paginator class ProjectsView(TemplateView): template_name = 'projects.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) project_post = ProjectPost.objects.order_by('-created_at') paginator = Paginator(project_post, 6) # Display 6 posts per page page_number = self.request.GET.get('page') page_obj = paginator.get_page(page_number) context['page_obj'] = page_obj return context class ProjectDetailsView(TemplateView): template_name = 'project_details.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) project_id = self.kwargs.get('project_id') project = get_object_or_404(ProjectPost, pk=project_id) context['project'] = project return context urls.py file: from django.urls import path from .views import ProjectsView, ProjectDetailsView urlpatterns = [ path('projects/', ProjectsView.as_view(), name='projects'), path('project_details/<int:project_id>/', ProjectDetailsView.as_view(), name='project_details'), ] For safe measure here is the models however I would like to achieve adding the title without adding a slug field if possible from django.db import models from ckeditor.fields import RichTextField from … -
Django ORM get data by pagination in query level?
I'm using Django ORM to get Employee modal data, but I have 1000-2000 data of employees in that table, now I want to get only one-page data at a time, for this raw query for 3rd page work like: SELECT * FROM employee LIMIT 30 OFFSET 60; and its ORM version is like this: page_number = 3 records_per_page = 30 offset = (page_number - 1) * records_per_page employees = Employee.objects.all().order_by('id')[offset:offset+records_per_page] I want to know if is this correct to use when a large number of data. Because here it gets Employee.objects.all() and then it offset records or it's working principle is different way??? -
How to calculate employee overtime and weekend pay in Django?
I have a problem with my django project. I'm trying develop a extra hours system but I don't know how to do it. I want to know how much I have to pay an employee for each month in overtime and weekends done. I have this model in django: ` class EmployeeExtra(models.Model): employee = models.ForeignKey(employees, on_delete=models.DO_NOTHING, verbose_name='Employee') job = models.ForeignKey(jobs, on_delete=models.DO_NOTHING, verbose_name='Job') date = models.DateField(verbose_name='Date') extra_hours = models.IntegerField(verbose_name='Extra Hours') price_extra_hour = models.ForeignKey(PriceExtraHours, default= True, on_delete=models.DO_NOTHING, verbose_name='Price Extra Hour') weekends = models.IntegerField(verbose_name='Weekends') price_weekend = models.ForeignKey(PriceWeekends, default= True, on_delete=models.DO_NOTHING, verbose_name='Price Weekend') ` Thank you! I didn't try anything because I have a blockage and I don't know where to start -
How do I deploy my Django project using PythonAnywhere?
Deploy Python / Django - Free Hosting Hosting Steps Server exit - ctrl+C press pip freeze > requirements.txt //this will create a file requirements.txt to our project that show all of our installed python libraries used in our project In vs code, right click our root project folder containing src and venv .click ‘reveal in file explorer’ or shift+alt+R or open our root folder. Then right click project folder in src.click ‘add to projectname.rar’ //compress to rar file. This file will be uploading to host the django project Go to pythonanywhere.com Sign up Create a beginner account Go to dashboard- click files - upload a file-then uload our ‘projectname.rar’ file Go to dashboard - click consoles - new console - click bash - this will open a terminal in browser Type pwd in cmd shows our current folder Type ls to show current files in the folder Type unrar x projectname.rar //to unzip our project file If it is zip file , then type unzip x projectname.zip ls - shows our project folder cd projectname/ ls - shows our files like manage.py,requirements.txt,.. Three lines right side, click help, django deploy , copy paste below code, Type mkvirtualenv –python=/usr/bin/python3.8 venv //this … -
Django templates loading issue
I have folder outside the djangoproject name custom_templates.I want to load only this templates from disk not from template caching. Everytime when i make changes in those templates dynamically ,template is loaded from cache not from disk.Thus iam unable to get updated content on web page. and my question is how to load templates from custom templates from disk in test and production servers where debug is set to False? template = loader.get_template(f'{path}/{theme_status}/html/private/base_template.html') This code is used to load template but iam getting template from cache -
?e=1 django in custom template
I need to display some aggregated data in my custom template. If i am not getting any params, i want to display the information the last month, othervise for the given period. But when no parameter is given, django tries to redirect me. How can i avoid this redirect? @admin.register(EmployeeStatistics) class EmployeeStatysticsAdmin(admin.ModelAdmin): change_list_template = 'admin/employee_amount_statistics.html' list_filter = ( ('created', DateRangeFilter), ) def get_queryset(self, request): params: dict = request.GET from_date = params.get('created__range__gte') to_date = params.get('created__range__lte') qs = super().get_queryset(request) if not params: # for the last month employee_data = qs.filter(created__date__gte=datetime.today() - timedelta(days=30))\ .aggregate( total_employees=Count('id'), new_employees=Coalesce(Sum(Case(When(is_fired=False, then=1), output_field=IntegerField())), Value(0)), fired_employees=Coalesce(Sum(Case(When(is_fired=True, then=1), output_field=IntegerField())), Value(0)) ) else: employee_data = qs.filter(created__date__gte=convert_date(from_date), created__date__lte=convert_date(to_date))\ .aggregate( total_employees=Count('id'), new_employees=Coalesce(Sum(Case(When(is_fired=False, then=1), output_field=IntegerField())), Value(0)), fired_employees=Coalesce(Sum(Case(When(is_fired=True, then=1), output_field=IntegerField())), Value(0)) ) return employee_data def changelist_view(self, request, extra_context=None): aggregated_data: QuerySet = self.get_queryset(request) response = super().changelist_view( request, extra_context=aggregated_data, ) return response -
Why time elapsed b/w `def startTest ` and `def stopTest` is coming very small when running django test with --parallel? [closed]
I have written a script to calculate time elapsed to run a django test. I'm doing it by calculating the time elapsed b/w def startTest and def stopTest. But when I'm running with --parallel flag it's coming very small? And yes I'm using shared resource(file), to store the time elapsed of each test. -
How to remember class active on page reload
I'm new, please tell me if it's possible to do this: there are navigation tabs on the page, I want the selected tabs to be active when the page is reloaded. So that the class="nav-link active" is remembered before reloading the page and automatically applied after reloading. P.s. while compiling the question, I came across sessionStorage, judging by the description, this is exactly what I need, explain to me, please, how can I apply this to my example? <nav> <div class="nav nav-tabs justify-content-center" role="tablist"> <button class="nav-link" data-bs-toggle="tab" data-bs-target="#region-{{ department.id }}" type="button" role="tab" aria-controls="region-{{ department.id }}">{{ department.department_name }</button> </div> </nav> <div class="tab-content"> <div class="tab-pane fade" id="region-{{ department.id }}" role="tabpanel"></div> </div> -
Celery task creating duplicate queues on high load
We have a shared task name create_child in celery and binding with queue child_A be below definition.. @shared_task(bind=True, queue="child_A") def create_child(self, **kwargs): When there is high load on create_child task we are experiencing in redis there is two queues got created. One is "_kombu.binding.child_A" and second is child_A. This causes some data loss and also after some time there is no data coming in celery worker, because the queue is not cleared. We are using redis as a broker for celery. Python version: 3.10 Celery version: 5.2.7 -
User can't create objects in the page
I made a program where users put their expenses to keep track of them, after they create their own account. So they fill 4 fields: customer,category, price and month, i would like that the first field(customer) is the same user that logged the account, because now, the user can choose from all 'customers'. But the other problem is that the users cannot create an object, i can only create it in the admin dashboard. Because when i try in the page it throws me this: "error: RelatedObjectDoesNotExist at / User has no customer". And i think that problem may be related to this: I notice that in the admin page, the users are add in the "authentication and authorization" section, inside the "Users". But they should be in "Customers" , created by my app alongside "Finance"(where objects are stored). Before putting my code, I summarize: I want the first field to be the same that the user who logged in. I want the user to be able to create an object from the page (i dont understand why it doesnt allow me anymore, a while back i could do it without problem) Thank you so much for your help. Model: … -
What does 'was not closed' mean in this Django error message?
my urls.py will not allow Django to run the server. The error message visual studio code gives when I hover over the red squiggly line that visual studio gives over the url patterns [ is: "[" was not closed. Can anyone explain to me what that error message means and how to solve it? Also, I am trying to get my Django server to run the server on its own. But it will not open the main page. It was able to run the other paths when I put the url after the /'finance' or /'ingredients' respectively but that was before the bug popped up. I am certain the error is tied to preventing Django to load the server. urls.py from django.contrib import admin from django.urls import include, path from django.http import HttpResponse urlpatterns = [ # <----- error is on this thing path('admin/',name ='inventory' admin.site.urls), path('finance/', finance, name='finance'), path('home/', home, name='home'), #I am attempting to connect the home_view function with the views function. path('ingredients/', ingredients, name='ingredients'), path('menu/', menu, name='menu'), path('purchases/', purchases, name='purchases'),] views.py def finance(request): return HttpResponse('Here are our business results') def home(request): return HttpResponse def ingredients(request): return HttpResponse('Here is the ingredients page') def menu(request): return HttpResponse('Here is the … -
Search Customers that are part of the logged on User's Business?
The code I currently have is this, in my views.py I can't figure out how to set up my search function. All other functions work. models.py class User(AbstractUser): """User can be Employee or Customer""" class Business(models.Model): business = models.CharField(max_length=50) class BusinessOwner(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, null=True ) business = models.ForeignKey(Business, on_delete=models.CASCADE, null=True) class Customer(models.Model): """ Customer-specific information """ user = models.OneToOneField(User, on_delete=models.CASCADE, null=True ) business = models.ForeignKey(Business, on_delete=models.CASCADE, null=True) class Employee(models.Model): """ Employee-specific information """ user = models.OneToOneField(User, on_delete=models.CASCADE, null=True) business = models.ForeignKey(Business, on_delete=models.CASCADE, null=True, blank=True)` forms.py class CustomerFilter(django_filters.FilterSet): business = django_filters.CharFilter(name='business', lookup_expr='icontains') customer = django_filters.CharFilter(name='customer', lookup_expr='icontains') user = django_filters.CharFilter(name='user', lookup_expr='icontains') class Meta: model = Customer fields = ['business', 'customer', 'user', ] class UserForm(UserCreationForm): class Meta: model = User fields = ( "username", "email", "password1", "password2", "first_name", "last_name", ) class BusinessOwnerForm(forms.ModelForm): . . . no fields class EmployeeForm(forms.ModelForm): . . . no fields class CustomerForm(forms.ModelForm): . . . no fields class BusinessForm(forms.ModelForm): class Meta: model = Business fields = ( "business", ) views.py (user creation process) #I am really not sure what to do in my view here. def searchUsers(request): results = [] if request.method == "GET": query = request.GET.get('search') if query == '': query = 'None' results = User.objects.filter(Q(customer__icontains=query)) … -
how do I fix NoReverseMatch error when i trying convert to class base my code?
I have some code and when it executes, it throws a No Reverse Match, saying: What does this mean, and what can I do about it? I m trying convert my code to class base and name space for my app. I have some code and when it executes, it throws a NoReverseMatch, saying: NoReverseMatch at /dashboard/leads/6/ Reverse for 'delete' with arguments '('',)' not found. 1 pattern(s) tried: ['dashboard/leads/(?P[0-9]+)/delete/$'] view.py class LeadDetailView(DetailView): model = Lead @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['form'] = AddCommentForm() def get_queryset(self): queryset = super(LeadDetailView, self).get_queryset() return queryset.filter(created_by=self.request.user, pk=self.kwargs.get('pk')) class LeadDeleteView(DeleteView): model = Lead success_url = reverse_lazy('leads:list') @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) def get_queryset(self): queryset = super(LeadDeleteView, self).get_queryset() team = self.request.user.userprofile.active_team return queryset.filter(team=team, pk=self.kwargs.get('pk')) def get(self, request, *args, **kwargs): return self.post(request, *args, **kwargs) class LeadUpdateView(UpdateView): model = Lead fields = ('name', 'email', 'description', 'priority', 'status',) success_url = reverse_lazy('leads:list') @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['title'] = 'Edit lead' return context def get_queryset(self): queryset = super(UpdateView, self).get_queryset() return queryset.filter(created_by=self.request.user, pk=self.kwargs.get('pk')) urls.py from django.urls import path from . import views app_name = 'leads' urlpatterns = [ path('', views.LeadListView.as_view(), name='list'), … -
How can I preview Excel files in-browser with Django and Python?
I am trying to view an excel file in browser. No editing is necessary, the users will just need to preview the files. I already have a working system for pdf, where my Django server opens the file in a new tab, but when I run the code for an excel file, it downloads the code rather, which isn't ideal, since I don't want to get licenses for all computers accessing the files. What are my options here? View.py res = download(token, path) with open(file_name, 'wb') as f: f.write(res.content) with open(file_name, 'rb') as f: res = HttpResponse(f.read(), content_type=res.headers['Content-Type']) This is the Python-Django code that opens the file. Again, works great for previewing PDF, but I need to preview Excel/Docs files as well. -
All users share the same data created, how do i fix it?
I made a program where users put their expenses to keep track of them, after they create their own account. But when i test it, all users share the same table. Ex: Lets say user 1, add to the table "Rent: $2500", but when i close that account and open a new one (User 2), i can see the expenses of the other Users in the page. Please help me, I've been putting a lot of time trying to solve it but i cant. Thanks in advance Model: class Customer(models.Model): user = models.OneToOneField(User, null=True, on_delete=models.CASCADE) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True,blank=True) date_created = models.DateTimeField(auto_now_add=True, null=True) # def __str__(self): # return self.name (i don't now if it's correct) class Finance(models.Model): expenses_category = [ ("Saving", "Saving"), ("Food", "Food"), ("Bills", "Bills"), ("Rent", "Rent"), ("Extra", "Extra"), ] expenses_month = [ ("January", "January"), ("February", "February"), ("March", "March"), ("April", "April"), ("May", "May"), ("June", "June"), ("July", "July"), ("August", "August"), ("September", "September"), ("October", "October"), ("November", "November"), ("December", "December"), ] customer = models.ForeignKey(User, on_delete=models.CASCADE, null=True,blank=True) category = models.CharField(choices=expenses_category, max_length=200) price = models.IntegerField() month = models.CharField(choices=expenses_month, max_length=200) Views: @csrf_exempt def registerPage(request): if request.user.is_authenticated: return redirect('home') else: form = CreateUserForm() if request.method == 'POST': form = CreateUserForm(request.POST) if form.is_valid(): … -
django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19)
I am getting this error when I try to run my django server locally: "django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19).". The local django server is connected to a postgres instance hosted on ElephantSQL. I have installed psycopg2-binary==2.9.6. But when I run "python manage.py runserver", I get the error "django.db.utils.NotSupportedError: PostgreSQL 12 or later is required (found 11.19).". I tried upgrading my computer's postgres with homebrew, up to 12.5. This did not fix the problem, as I still get the same error (which still mentions 11.19). I do not know what instance of postgres this 11.19 refers to, and how to update it to 12 or above. Ideas? Note- another stack overflow post about this suggested downgrading my django version from a 4 to a 3, but this seems like a bad way to fix it. -
Upload file in django plotly don't working
I build a module to analyze a file and return a plotly graphic. Now i need to implement im django template, but can't integrate a upload file in my plotly module. I can make the upload and the function it's working, but i can't using together. The situation is: I need a to upload a file, make the analyze with a plotly function and return a graphic. This is my django view code: def test_page(request): directory = 'C:\\tmp\\Uploads\\' if request.method == 'POST': upload_file = request.FILES['document'] fs = FileSystemStorage(location=directory) filename = upload_file.name url = fs.url(upload_file) file = directory + filename print(file) #plotly function UFLGplots = visualization_Django_Dash.build_GRplots(file) context = { 'UFLGplots': UFLGplots, } return render(request, 'index.html', context) When i make the runserver the firt error is The varible file is empty. I want to call the plotly function just when i make the upload file. -
Is it possible to specify a foreign key for a table field in Django models.py to any table from the database?
Suppose there is a table in the database "table", not created by Django. Is it possible to specify it as a foreign key in any way? class Object(models.Model): object_id = models.IntegerField(unique=True) param = models.ForeignKey('table', on_delete= models.DO_NOTHING) ... -
The 'mainimage' attribute has no file associated with it. While sending a signal
I'm trying to send a signal when the post is created like this @receiver(post_save, sender=Post) def new_post_saved(sender, instance, created, **kwargs): if created: user = instance.author user_id = instance.author.id post_id = instance.id post_title = instance.title post_content = instance.content post_mainimage = instance.mainimage.url if instance.mainimage else None # Check if mainimage has a file associated with it post_rpfile = instance.rpfile if instance.rpfile else None post_version = instance.version post_xnumber = instance.xnumber post_category = instance.category post_date = instance.date_added post_likes = instance.likes.count() webhook_url = "" session = requests.Session() webhook = SyncWebhook.from_url(webhook_url, session=session) # To send a message e = discord.Embed(title=f"{post_title}", description=f"{post_content}", color=discord.Color.from_rgb(255, 0, 0)) e.add_field(name='Download', value=f"[Click here](https://my-project.mrahmed2.repl.co/{post_rpfile})") e.add_field(name="likes", value=f"{post_likes}") e.add_field(name="version", value=f"{post_version}") e.add_field(name='x number', value=f"{post_xnumber}") e.set_image(url=f"https://my-project.mrahmed2.repl.co/{post_mainimage}") e.set_footer(text=f'{post_date}') webhook.send(embed=e) but i get this error The 'mainimage' attribute has no file associated with it. and the mainimage has no file associated with it becouse i use this function on my image filed def thumbnail_upload_to(instance, filename): return f'resourepacks/{instance.id}/images/thumbnail/{filename}' and of course i use save function to update those two fileds after the post is created so the instance.id in the thumbnail_upload_to function not = None **so my path will be ** ------resourepacks -----------1 ----images -thumbnail -test.jpg my save function def save(self, *args, **kwargs): if self.pk is None: saved_image = self.mainimage … -
How to assign an order to field in a many to many field
This is my first django project so I'm still learning. I Django project of Formula One Races and Racers. The Race model looks like this, class Race(models.Model): name = models.CharField(max_length=250) location = models.CharField(max_length=250) date = models.DateField() track = models.URLField() comments = models.TextField() @property def has_passed(self): return self.date < date.today() class Meta: ordering = ["date"] def __str__(self): return self.name and the racers look like this, class Players(models.Model): name = models.CharField(max_length=250) country = models.CharField(max_length=250) team = models.ForeignKey( Teams, related_name = "players_team", on_delete = models.CASCADE ) races = models.ManyToManyField( Race, related_name= "results", ) class Meta: ordering = ["name"] def __str__(self): return self.name I want to be able to assign a different order to the racer for each race to show the race results. How would I be able to assign this order? Thank you I tried to manually assign ordering on by creating a result model, I feel like that is clunky. -
When using Router in react its not showing data from database but without Router its working
When using Router in react its not showing data from database but without Router its working But when router with defined function in routes.js its not showing data from server side App.js import React, {Component} from 'react'; import { BrowserRouter as Router} from 'react-router-dom'; import BaseRouter from './routes'; import 'antd/dist/reset.css'; import CustomLayout from './container/layout'; // import ArticleList from './container/ariclelistview'; //not working class App extends Component{ render(){ return( <div className='App'> <Router> <CustomLayout> <BaseRouter/> </CustomLayout> </Router> </div> ); } } // working // class App extends Component{ // render(){ // return( // <div className='App'> // <CustomLayout> // <ArticleList/> // </CustomLayout> // </div> // ); // } // } export default App; routes.js import React from "react"; import ArticleList from './container/ariclelistview'; import { Route } from 'react-router-dom'; const BaseRouter = () => { <div> <Route exact path ='/' Component={ArticleList} /> <Route exact path ='/:articleID' Component={ArticleList} /> </div> }; export default BaseRouter; ArticleList.js import React from "react"; import Articles from "../components/articles"; import axios from 'axios'; const data = Array.from({ length: 23, }).map((_, i) => ({ href: 'https://ant.design', title: `ant design part ${i}`, avatar: `https://xsgames.co/randomusers/avatar.php?g=pixel&key=${i}`, description: 'Ant Design, a design language for background applications, is refined by Ant UED Team.', content: 'We supply a series … -
How to generate a fake HTTP request object for unit test in Python?
In a Python Django project, we want a unit test to feed a HTTP POST request into the function under test. The cURL sample command below shows our test settings. The cURL approach starts from the web server's endpoint and triggers the entire logic path, but we want the unit test to focus on a specific function taking in the request argument. And, we got hint from this post with the below sample Python source code to fake a HTTP request for testing. Our Question: See the -d argument of the cURL command, we wonder how to feed the request body in the faked object. Technical Details: The cURL command: curl http://127.0.0.1:8000/api/transaction/ --insecure \ --verbose \ -d '<env:Envelope ... > <env:Header> ... </env:Header> <env:Body> ... </env:Body> </env:Envelope> ' The Python sample source code for faking a HTTP request: from django.core.handlers.wsgi import WSGIRequest from io import StringIO from django.contrib.auth.models import AnonymousUser def GetFakeRequest(path='/', user=None): """ Construct a fake request(WSGIRequest) object""" req = WSGIRequest({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': path, 'wsgi.input': StringIO()}) req.user = AnonymousUser() if user is None else user return req -
NGINX Django DRF Vue.js POST method returns Method Get not allowed 405
I am building an ecommerce site. Everything works well, except the forms. When I try to post something, it returns me 405 method get not allowed. Why is it giving GET error when I am trying to do POST? It works on some forms, like for example checkout. But when I try to use contact form and press send axios.post('/api/v1/contacto/', data) it gets me this error 405. BTW, when I am using this e-commerce running it on my local machine, it works well. Here is my sites-available: upstream ecologic_app_server { server unix:/webapps/ecologic/backend/venv/run/gunicorn.sock fail_timeout=0; } server { listen 8000; listen [::]:8000; server_name myiphere; client_max_body_size 40M; location / { root /webapps/ecologic/frontend; try_files $uri /index.html; index index.html index.htm; } location /static/ { root /webapps/ecologic/backend; } location /media/ { root /webapps/ecologic/backend; } location /api/v1/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_set_header Host $http_host; proxy_pass http://ecologic_app_server/api/v1/; proxy_ssl_session_reuse off; proxy_redirect off; } location /admin/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_pass http://ecologic_app_server/admin/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; } } This is my urls.py: from django.urls import path, include from . import views urlpatterns = [ path('contacto/', views.contact_form_post), path('reclamo/', views.complaints_form_post), ] Here is my code for contact …