Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to store dark mode choice with Javascript in Django?
This post is hidden. You deleted this post last month. I have the following script NioApp.ModeSwitch = function() { var toggle = $('.dark-switch'); if($body.hasClass('dark-mode')){ toggle.addClass('active'); }else { toggle.removeClass('active'); } toggle.on('click', function(e){ e.preventDefault(); $(this).toggleClass('active'); $body.toggleClass('dark-mode'); }) } Which changes the website to dark-mode, through this toogle <li><a class="dark-switch" href="#"><em class="icon ni ni-moon"></em><span>Dark Mode</span></a></li> How can I, in Django, store this with Javascript, so that it remembers the user option? -
Running a py file as a script Django
I have created a Django app which I have uploaded to PythonAnywhere. I want to use the below code to run as a separate task, which basically runs through all of the bookings in the system and sends an email if the booking has passed today's date. I previously had this in the Views.py file and the code works fine when the page refreshes but I basically want it to be run separate each morning at a particular time. The issue I am having if I try to run the py file even locallly "py completed_bookings.py" it does not recognise any of the imports. Examples include "ModuleNotFoundError: No module named 'sendgrid'" and "ImportError: attempted relative import with no known parent package" I think this may be down to the structure or the way I am trying to run it but unsure how this is suppose to be done. Currently this file is sitting with the rest of my app files. Thanks in advance for any help. Below is the py file I created in the app to be run separate. from datetime import datetime, timedelta import datetime from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail from twilio.rest import Client import … -
Getting 'No changes detected in learning_log' in new Django project
I'm new to python and django, and I'm following a tutorial from the Python Crash Course book 2nd edition, for creating a simple website. This is my first time using django. I am simply following along with the book, but I have run into a roadblock with the error 'No changes detected in learning_log'. I'm using django 2.2 for this project if that makes any difference. Here are my installed apps in settings.py INSTALLED_APPS = [ # My Apps 'learning_logs', # Default Apps 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] Here is the DATABASES code in settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # I had to change this from 'NAME': BASE_DIR / 'db.sqlite3' 'NAME': str(BASE_DIR / 'db.sqlite3'), } } Note: I changed 'NAME': BASE_DIR / 'db.sqlite3' to 'NAME': str(BASE_DIR / 'db.sqlite3') to address a previous error: 'TypeError: argument of type 'WindowsPath' is not iterable' To migrate the database I used python manage.py makemigrations learning_logs (ll_env) PS C:\Users\Admin\documents\scripts\pythondir\learning_log> python manage.py > makemigrations learning_logs this resolved the TypeError, but is still giving me the message 'No changes detected in app 'learning_logs''. I used verbosity to give me more details and it gave me this information (ll_env) PS C:\Users\Admin\documents\scripts\pythondir\learning_log> python manage.py … -
¿como puedo tener todas sus Reservas? foreing key django
Como puedo obtener los datos relacionados de mi foreignkey y al llenar mi formulario, tengo mi modelo class Service(models.Model): branch = models.ForeignKey(Endpoint, verbose_name="Sucursal", on_delete=models.CASCADE) pr = models.CharField(max_length=50, null=True, blank=True, verbose_name="prueba") lo que quiero es que al seleccionar la relacion que trae "branch", me llene en el otro campo en este caso "pr" ponga los otros datos que trae esa relacion de "branch". -
Django : Related Field got invalid lookup: user
I want to find practice data based on the user primary key. So when I open the url: localhost:8080/api/practice-filter?user=1 it will output all practice data based on the user with id 1. model.py class Practice(models.Model): practice_id = models.BigAutoField(primary_key=True) user = models.ForeignKey('User', models.DO_NOTHING, default=None) score = models.SmallIntegerField(null=True) class Meta: managed = True db_table = 'practice' def __str__(self): return str(self.practice_id) class User(models.Model): user_id = models.BigAutoField(primary_key=True) fullname = models.CharField(max_length=50) email = models.CharField(max_length=100) password = models.TextField() class Meta: managed = True db_table = 'user' def __str__(self): return self.fullname view.py @api_view(['GET']) def practice_filter(request): if request.method == 'GET': exercises = Practice.objects.all() user = request.GET.get('user', None) if user is not None: practice_filtered = exercises.filter(user__user__icontains=user) exercises_serializer = PracticeSerializer(practice_filtered, many=True) return JsonResponse(exercises_serializer.data, safe=False) But when i run the above code i get an error : Related Field got invalid lookup: user How to solve this error? I do not know what to do. I'm still a beginner and need a lot of guidance. Please help. Thank you. -
How to render multiple outputs from a function triggered by an html form in Django
Ive been creating a website that essentially replaces financial analysts. I've been adding projects that calculate various statistics and models, however I cant figure out how to have multiple outputs (organized in different containers) for one request returned on the page. Clarification (2 parts): For example, I have one section that is a financial statement builder. The input from the HTML form is a ticker, the view takes the request, calls the statement builder function and returns the statements as an html table, so I can render it in one location. Now, another section is a fundamental financial statistics calculator. It takes in the ticker for the form input which is used as the parameter for the function, however it calculates about 25 different ratios and metrics. I want to organize these on a data dashboard (everything else is built) , however am not sure how to organize multiple outputs in different locations from one request. Thank you for any help! -
Django tinymce htmlfield being displayed as textfield in production
I have a tinymce htmlfield on mysite, and while testing it on localhost it displays as normal, but when i commit it to my site and access its admin, the field is displayed as if it was a textfield here it is in localhost and here it is in production here's what the console on my site shows settings.py INSTALLED_APPS = [ 'grappelli', 'filebrowser', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tinymce', -
no such table: users_user
I need to create POST method Registration Form i have this code (i am using django rest_framework): Users.models class User(AbstractBaseUser): username = models.CharField(max_length=20, unique=True) email = models.EmailField(unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELD = 'username' class MyUserManager(CreateAPIView): def post(request, *args, **kwargs): username = request.data.get('username') email = request.data.get('email') password = request.data.get('password') user = model(username=username, email=normalize_email(email)) user.set_password(password) return user users.serializers: class MyUserManagerSerializers(serializers.ModelSerializer): username = serializers.CharField(max_length=20) email = serializers.EmailField() password = serializers.CharField() class Meta: model = models.User fields = ['email', 'username', 'password'] and models.views.py: class UserManagerAPIView(ListCreateAPIView): serializer_class = MyUserManagerSerializers def UserRegistration(request): user = UserManager.post(request) serializers = MyUserManagerSerializers(user) serializers.is_valid(raise_exception=True) serializers.save() return Response(serializer.data, status=status.HTTP_201_CREATED) urls.py urlpatterns = [ path('register', UserManagerAPIView.as_view()), and installed_apps: INSTALLED_APPS = ['users.apps.UsersConfig'] AUTH_USER_MODEL = 'users.User' when i am send POST method to localhost:8000/register i always get error: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 423, in execute return Database.Cursor.execute(self, query, params) The above exception (no such table: users_user) was the direct cause of the following exception: File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, … -
How can I append data from html to array in views from a button?
I'm trying to build a website that generates a power hour style video from a list of music videos that the user selects by searching through the youtube api. I'm having trouble figuring out how to append selected videos to a list (addedVideos) in view.py from a button (add) in my html. I need to append each added video to a list so I can display them and loop through them in an embedded youtube player. This is my first django project so I don't have a good understanding of what the potential problems could be. index.html and views.py below: views.py import requests from isodate import parse_duration from django.conf import settings from django.shortcuts import render, redirect def index(request): addedVideos = [] videos = [] if request.method == 'POST': search_url = 'https://www.googleapis.com/youtube/v3/search' video_url = 'https://www.googleapis.com/youtube/v3/videos' search_params = { 'part' : 'snippet', 'q' : request.POST['search'], 'key' : settings.YOUTUBE_DATA_API_KEY, 'maxResults' : 3, 'type' : 'video' } #print(request.POST['submit']) r = requests.get(search_url, params=search_params) #print(r) results = r.json()['items'] #print(results) video_ids = [] for result in results: video_ids.append(result['id']['videoId']) if request.POST['submit'] == 'lucky': return redirect(f'https://www.youtube.com/watch?v={ video_ids[0] }') video_params = { 'key' : settings.YOUTUBE_DATA_API_KEY, 'part' : 'snippet,contentDetails', 'id' : ','.join(video_ids), 'maxResults' : 3 } r = requests.get(video_url, params=video_params) results … -
S3 Lambda Trigger not triggering for EVERY file upload
In Python Django, I save multiple video files. Save 1: Long Video Short Video Save 2: Long Video Short Video Save 3: Long Video Short Video I have a lambda trigger that uses media converter to add HLS formats to these videos as well as generate thumbnails. These 3 saves are done in very short time periods between each other since they are assets to a Social Media Post object. For some reason the S3 triggers for only some of the files. Save 1 triggers S3 Lambda but not Save 2. Save 3 also triggers S3 Lambda. My assumption is that the S3 trigger has some sort of downtime in between identifying new file uploads (In which case, I think the period in between these file uploads are near instant). Is this assumption correct and how can I circumvent it? -
Django link form to fields to model
Im abit confused on how to link form fields to the model field. I wanted to create a radio button that yes stands for "defect" and no for "No Defect. So in the form i created the following: CHOICES = [('Defect', 'yes'), ('No Defect', 'no')] self.fields['Audit_outcome'].widget = forms.ChoiceField(choices=CHOICES) But when i do that i get the following error: 'ChoiceField' object has no attribute 'attrs' -
How to pass string to content of meta tag for template?
{% if is_inner_page %} <meta name="description" content={{ description }}> {% else %} <meta name="description" content="Text sample"/> {% endif %} When i passed string to template with render in view, I get only first word of string in content, so how to pass full string of description to template? If i pass not in content, then all is ok, please help me :( -
How to implement tinymce with django for client side?
I did lot of research on how to implement django tinymce for users and not for admin but I got no real answer. Is there any way to do it. Any help would be highly appreciated... -
Django not able to see data from the model on web page
I am trying to build a project management system but I am not able to see the data from the models on the web page. My code is below. Also, I am not sure if the data is getting stored in the database at all. models.py from django.contrib.auth.models import AbstractUser from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver class CustomUser(AbstractUser): user_type_data = ((1, "Admin"), (2, "Staff"), (3, "Client")) user_type = models.CharField(default=1, choices=user_type_data, max_length=10) class AdminUser(models.Model): id = models.AutoField(primary_key=True) admin = models.OneToOneField(CustomUser, on_delete = models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) objects = models.Manager() class Staffs(models.Model): id = models.AutoField(primary_key=True) admin = models.OneToOneField(CustomUser, on_delete = models.CASCADE) phone = models.CharField(max_length=15, unique=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) objects = models.Manager() views.py from django.shortcuts import render, redirect from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.contrib import messages from django.core.files.storage import FileSystemStorage #To upload Profile Picture from django.urls import reverse from django.views.decorators.csrf import csrf_exempt from django.core import serializers import json from powercons_app.models import CustomUser, AdminUser, Staffs, Projects, Tasks, Clients, Contracts from .forms import AddClientForm, EditClientForm def add_staff(request): return render(request, "admintemplate/add_staff_template.html") def add_staff_save(request): if request.method != "POST": messages.error(request, "Invalid Method ") return redirect('add_staff') else: first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') username = … -
How to add a complex constraint on a Django Model?
Dashboards have a team and a user associated with them and have an is_default key. I want to ensure that the is_default key can only be set once as True for each user + company. The user should still be able to create an unlimited amount of is_default=False dashboards. I want to use Djangos constraints for this. However I don't know how to set those up. Here is what I tried so far: constraints = [ models.UniqueConstraint(fields=['user', 'company'], condition=Q( is_default=True), name='unique_primary_dashboard') ] I also tried using the CheckConstraint but I couldn't figure out how to query for the right paramters. At the moment my code apparently restricts nothing. -
How to cascade delete only when last FK relation is deleted in Django?
Given a Many-to-many relation in Django: class Agent: stuff = chars class Protegee: agents = models.ManyToManyField(Agent, related_name="protegees") I'd like a Cascade behaviour on the Protegee, but only if no more agents are related. I.e. as long as a protegee has at least one Agent, it keeps existing. Is there a built-in for that? -
Sudo pip warning inside of docker
I am making simple image of my python django app in docker. But at the end of the building container it throws next warning (I am building it on Ubuntu 20.04): WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead. Why does it throw this warning if I am installing requirements on python inside my image as I understood. I am building my image using sudo docker build -t my_app:1 .. Should I be worried about warning that pip throws, because I know it can break my system?. Here is my dockerfile FROM python:3.8-slim-buster WORKDIR /app COPY requirements.txt requirements.txt RUN pip install -r requirements.txt COPY . . CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] -
How to fix IntelliJ can't run shell or server in terminal?
I had some trouble importing the right module register() in my urls.py, because I had defined a function register() inside a viwes.py in another folder in the same directory. I have attatched a picture: I think it has something to do with the fact that I was working in Programs/mysite/mysite/urls.py and wanted to import from Programs/mysite/register/views.py but Python couldn't find the right module. A pop-up window asked if I wanted to fix the problem by importing someting called registry from Django and I clicked yes because i mistook it for saying 'register'. As you can see in the picture, all files in my register are red now, but I don't know why. I first tried refactoring the folder to 'reguser' instead, and refactored all the usages of 'register' to 'reguser'. I thought that may be the cause of the error, but according to the error-messages I get, I think the problem has something to do with Django.apps.register because I tried running the server to see if it worked, but then I got this error message: The last line in the error-message states " OSError: [WinError 123] Filename, foldername or volumenamesyntax is wrong:'' " Then I tried to open the shell … -
Distance Postgis Django Postgres
i try to develop a estate property app. Now i have app searchcriteria and app estates. searchcriteria.models.py: geopoint = models.PointField(null=True, blank=True) distance = models.PositiveSmallIntegerField(blank=True, default=0, null=True) estates.models.py: geopoint = models.PointField(null=True, blank=True) As you can see searchcriteria and estates have a Pointfield. Now i want from one estate instance search all searchcriteria how match to this estate. Problem is that every searchcirteria have it's own distance entry so circle is different. I now only such Q: Q(geopoint__distance_lte=(searchcriteriageopoint, Distance(km=30))) but this don't work here because different distance per searchcriteria. I found a website: https://blog.programster.org/using-postgis-to-calculate-distance-between-two-points so in as SQL Query i think following is right: SELECT * FROM searchcriteria.Searchcriteria a, estates.Estates b WHERE ST_Distance_Sphere(geometry(a.geopoint), geometry(b.geopint)) < a.distance; How can i write it as Q()? -
Django - Are all relevent models needed when testing the URL of a functional view?
I have several functional views that are passed parameters. I'm trying to write tests to check the url, status, etc. So far I'm starting with just testing the URL name. I have some querysets in the view and it looks from the traceback that I need to define objects for the queries in my setUp urls app_name = 'gradebook' urlpatterns = [ path('updatesinglegrade/<int:assess_pk>/<int:class_pk>/<int:grade_pk>/', views.updatesinglegrade, name='updatesinglegrade'), ] view def updatesinglegrade(request, assess_pk, class_pk, grade_pk): grade = Grade.objects.get(id=grade_pk) gradescale = GradeBookSetup.objects.get(user=request.user) scale_choice = grade_scale_choice(gradescale.scale_mode) form = UpdateGradeForm(gradescale=scale_choice) context = {'form': form} context['grade'] = grade if request.method == 'POST': form = UpdateGradeForm( request.POST, gradescale=scale_choice) if form.is_valid(): cd = form.cleaned_data grade.score = cd['score'] grade.save() return redirect('gradebook:assessdetail', assess_pk, class_pk) else: return render(request, "gradebook/grade_single_form.html", context) else: return render(request, "gradebook/grade_single_form.html", context) test class UpdateSingleGradeTests(TestCase): def setUp(self): self.user = CustomUser.objects.create_user( username='tester', email='tester@email.com', password='tester123' ) login = self.client.login(username='tester', password='tester123') def test_updatesinglegrade_url_name(self): response = self.client.get(reverse('gradebook:updatesinglegrade', kwargs={ 'assess_pk': 1, 'class_pk': 2, 'grade_pk': 3})) self.assertEqual(response.status_code, 200) traceback ====================================================================== ERROR: test_updatesinglegrade_url_name (gradebook.tests.UpdateSingleGradeTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Doug\OneDrive\django\gradebook\gradebook\tests.py", line 102, in test_updatesinglegrade_url_name response = self.client.get(reverse('gradebook:updatesinglegrade', kwargs={ File "C:\Users\Doug\.virtualenvs\gradebook-6RQSg7dk\lib\site-packages\django\test\client.py", line 742, in get response = super().get(path, data=data, secure=secure, **extra) File "C:\Users\Doug\.virtualenvs\gradebook-6RQSg7dk\lib\site-packages\django\test\client.py", line 396, in get return self.generic('GET', path, secure=secure, **{ File "C:\Users\Doug\.virtualenvs\gradebook-6RQSg7dk\lib\site-packages\django\test\client.py", line … -
What's the best way to style an email template in Django?
I am trying to style an email template in Django. From researching the best way to do this seems to be to do inline CSS styles. This seems like it would be a tedious process so was wondering if anyone has any better suggestions? I saw another suggestion saying to use django-inlinecss but I can't for the life of me locate the css file when using {% inlinecss "static/css/email.css" %} Path of template: Coronavirus_Dashboard/home/templates/home/newsletter_emails/newsletter_body.html Path to CSS: Coronavirus_Dashboard/static/css/email.css I just keep getting a file not found error, not sure what way I need to specify the location. -
I'm creating a social web using django, I need to create a group model with an group admin who can perform activities such as add and remove members
I'd like that when a group is created then the instance of the profile that creates the group automatically becomes the group admin likewise he/she becomes a group member,couple of basic methods tried returns manytomany relationship errors pointing at add,set functions, how can this be achieved??, I'm using django restframework. Groups model. class Group(models.Model): group_name = models.CharField(max_length=200, blank=True) description = models.TextField( help_text='Describe this group...', max_length=350, blank=True) admin = models.OneToOneField( "profiles.Profile", blank=True, on_delete=models.SET_NULL, null=True, related_name='group_admin') members = models.ManyToManyField( "profiles.Profile", blank=True, related_name='members') posts = models.ForeignKey( "posts.Post", blank=True, on_delete=models.SET_NULL, null=True, related_name='group_posts') created_by = models.ForeignKey( "profiles.Profile", on_delete=models.SET_NULL, null=True, related_name='group_creator') created = models.DateTimeField(auto_now=True) -
how to join a table more than once when a table references different rows of that table
I have a table which can have up to 3 references to another table. here it is in my Django ORM class CreatorCategories(models.Model): name = models.CharField(max_length=100, unique=True) icon = models.CharField(max_length=200, unique=True) class ContentCreatorUsers(models.Model): creatorcategory1 = models.ForeignKey(CreatorCategories, related_name='creatorcategory1', on_delete=models.DO_NOTHING, null=True, blank=True) creatorcategory2 = models.ForeignKey(CreatorCategories, blank=True, related_name='creatorcategory2', null=True, on_delete=models.SET_NULL) creatorcategory3 = models.ForeignKey(CreatorCategories, blank=True, null=True, related_name='creatorcategory3', on_delete=models.SET_NULL) topbannerphotokey = models.CharField(max_length=100, null=True, blank=True) I am running a sql query in a aws lambda (I have not added the select statements that will get the values for a categories name and icon) SELECT id, creatordisplayname, contentcreatordisplaycardurl, creatorurlslug, currentmonitaryactioncount, isverifiedcontentcreator FROM users_contentcreatorusers INNER JOIN users_creatorcategories ON users_contentcreatorusers.creatorcategory1_id= users_creatorcategories.id INNER JOIN users_creatorcategories ON ISNULL(users_contentcreatorusers.creatorcategory2_id, NULL) = ISNULL(users_creatorcategories.id, NULL) INNER JOIN users_creatorcategories ON ISNULL(users_contentcreatorusers.creatorcategory3_id, NULL) = ISNULL(users_creatorcategories.id, NULL) WHERE approvedcreator = true ORDER BY currentmonitaryactioncount DESC LIMIT 12; this sql query keeps giving me the same error: Traceback (most recent call last): File "browsecontentcreatorstest.py", line 115, in <module> lambda_handler() File "browsecontentcreatorstest.py", line 57, in lambda_handler cur.execute(''' psycopg2.errors.DuplicateAlias: table name "users_creatorcategories" specified more than once I need to be able to grab the name and the icon of each of the categories a creator has. I'm not sure how to do this without joins. And the documents I have … -
Add script tag to all django templates
My Django app contains 100+ HTML templates (should've made a web app). I need to add a user feedback widget similar to Usersnap. One way is to add a script tag to all of the 100+ template files and make sure it's added in all future files as well. Is there a way to add the script tag without repeating the code 100+ times? -
Problem with static files in django heroku
I have sam problems this static files in django. I sucsesfull deploy django app to heroku and this site workin https://timon-webchat.herokuapp.com/, but how you can see without any styles or images. But if runing python manage.py runserver local all good and I can see styles, js-codes and images Please tell me what's wrong here is mine setings.py file: """ Django settings for web_chat project. Generated by 'django-admin startproject' using Django 3.1.7. For more information o n this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. from django.urls import reverse_lazy import os import django_heroku BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '+*yv5wtriwzs91yk!gpu27r!p+b1063n26bpjf79+=236yu4%t' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['0.0.0.0', 'localhost', '127.0.0.1'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_gravatar', 'app_chat', 'acounts', ] AUTH_USER_MODEL = 'acounts.User' LOGIN_REDIRECT_URL = reverse_lazy("main") LOGOUT_REDIRECT_URL = reverse_lazy("login") MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] MIDDLEWARE_CLASSES = …