Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django renders a template that does not exist in specified directory
I have model 'Video' and I have a list view for this model, then in another app I'm trying to create a view 'UserVideosListView' that is viewable to the dedicated user. when I open the page in the browser before making any templates for this view I'm able to see current user's videos (not all videos). # inside 'users' app class UserVideosListView(ListView): model = Video template_name = "users/user_videos.html" context_object_name = 'videos' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['videos'] = Video.objects.filter(author=self.request.user) return context # inside 'videos' app class VideoListView(ListView): model = Video paginate_by = 25 template_name = 'videos/video_list.html' context_object_name = 'videos' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['videos'] = Video.published_videos.all() return context P.S. I'm sure that the URL I'm entering is current, and there is no template inside the 'users' directory -
Type Error: cannot read property length of undefined for empty_value_check
These are the javascript functions for my html form, to validate for empty values in "input" elements and "select" elements respectively. The empty_select_check function doesn't work and I'm not sure why, but the empty_value check works for the individual fields. However, it does not work in the empty_value_all() fucntion. Note that the empty_value_all() is called when the user clicks submit. I get the following error: Type Error: cannot read property length of undefined for empty_value_check. Any idea why it works for individual fields but not for when i try to submit? Let me know if you require my html code but basically its just input elements with an onkeyup="" where I call the js functions. function submitform(){ empty_value_all() $('#Start').click() } } function empty_value_check(ele) { let value = ele.value; console.log(value) if (value === '' || value.length === 0) { if ($(ele).closest('div').find('small').length != 0) $(ele).closest('div').find('small').removeClass('hide').removeClass('d-none'); else $(ele).closest('div').nextAll('small').removeClass('hide').removeClass('d-none'); $(ele).addClass('is-invalid'); } else { $(ele).nextAll('small').addClass('hide'); $(ele).removeClass('is-invalid'); } } function empty_select_check(ele) { if (ele.value === "Select Folder" || ele.value === undefined) { $(ele).addClass('invalid-feedback'); return false } else { $(ele).removeClass('is-invalid'); } } $(function() { $('#field_5,#field_6,#field_7').on('change', empty_select_check(this)) }) function empty_value_all() { $('#field_1,#field_2,#field_3',#field_4).each(empty_value_check(this)); $('#field_5,#field_6,#field_7').each(empty_select_check(this)); return false; } -
How to send a video to Flutter client from Django backend
I am a beginner in mobile development and I am creating a mobile app using Flutter on the client side and Django as backend. I am basically sending some images from the client to the server and processing them on the server side. I now want to send a video back to the client and play it in the Flutter app. I am currently trying to do this using an HTTP FileResponse in Django, and in Flutter I am writing the received response data as bytes in a file and displaying it with a VideoPlayer object. I think I may not be using the right encoder/decoder for this as the video won't playback (even when I try accessing the file directly from my phone). Also I am not sure this is the right approach to get my video playing in the client app, since I don't necessarily want to download the video on the client side (and store it as a file) but just display it on the screen, but I don't know in what other way I could achieve what I'm looking for. I have looked up how to stream a video but I haven't found any useful answers … -
Django form getting GET request instead POST request
Previously this code was sending post request. Suddenly after restarting server, it started sending get. If I take some working post code for form from internet and then go on trying and erasing then my code starts sending post request. But again after some time when I put my original code, this will start sending get request instead of post request. user_registration_form.html <form method="post"> {% csrf_token %} {{ form }} </form> <input type="submit" value="Register"> forms.py from django.forms import ModelForm from django import forms from .models import StudentData class StudentRegister(ModelForm): class Meta: model = StudentData fields = "__all__" widgets = {'password': forms.PasswordInput(), 'rpassword': forms.PasswordInput()} def clean(self): cleaned_data = super().clean() password, rpassword = cleaned_data.get('password'), cleaned_data.get('rpassword') if password != rpassword: error_msg = "Both passwords must match" self.add_error('rpassword', error_msg) views.py from django.shortcuts import render from .forms import StudentRegister from django.contrib import messages def login_register(request): return render(request, 'users/login_register.html') def guest_register(request): return render(request, 'users/guest_register.html') def student_data(request): if request.method == 'POST': print('post') form = StudentRegister(request.POST) if form.is_valid(): print('valid form') form.save() messages.success(request, f"You are registered successfully, {form.cleaned_data.get('name')}") return render(request, "<h3>Registration done</h3>") else: print('get') form = StudentRegister() return render(request, 'users/user_registration_form.html', {'form': form}) #models.py from django.db import models from django.core.validators import MaxLengthValidator class StudentData(models.Model): name = models.CharField(max_length=100) room_no = models.CharField(max_length=4) … -
Converting or Connecting Flask app.py code to Django
In our project, we are going to create a NLP web site. The user will going to write a text or upload a document and these api's going to help us to do processing. We made a api system with Flask but we made our web site backend with Django. I want to connect these two projects. Is it possible to connected them or I have to convert all the code we write on the django to flask. Flask app.py file: from flask import Flask, jsonify, request, render_template import requests import json app = Flask(__name__) app.config['JSON_AS_ASCII'] = False @app.route("/",methods=["GET"]) def home(): return render_template("SignPage.html") @app.route("/sentiment", methods=['POST']) def sentiment(): url = "http://localhost:5000/sentiment" payload = {"text": request.form["input_text"]} response = json.loads(requests.request("POST", url, json=payload).text) return jsonify(response) Django url.py file: urlpatterns = [ path('', views.index, name='kaydol'), path('anasayfa/', views.home, name='anasayfa'), path('duyguanalizi/', views.link1, name='duyguanalizi'), path('anahtarkelime/', views.link2, name='anahtarkelime'), path('özetleme/', views.link3, name='özetleme'), path('advarlık/', views.link4, name='advarlık'), path('sorucevap/', views.link5, name='sorucevap'), path('konutanım/', views.link6, name='konutanım'), ] urlpatterns += staticfiles_urlpatterns() Django views.py file: def index(request): if request.method == "POST": if request.POST.get('submit') == 'Kayıt Ol': username= request.POST['username'] email= request.POST['email'] password= request.POST['password'] if User.objects.filter(username=username).exists(): messages.info(request,'Bu kullanıcı adı kullanılıyor') return redirect('/') elif User.objects.filter(email=email).exists(): messages.info(request,'Bu email kullanılıyor.') return redirect('/') else: user = User.objects.create_user(username=username, email=email, password=password) user.save() return redirect('/') elif … -
how to set a default value in Django forms?
In the database there is class Borrowing which contains employee_id that will borrow item and tag_id (the item) and subscriber_id in my code, if an employee request a borrowing, he can choose subscriber_id. I need to set the subscriber_id to 1, without even asking the employee to choose. in the models.py file class Borrowing(models.Model): borrowing_id = models.IntegerField(null=True) start_date = models.DateField(auto_now_add=True, null=True) end_date = models.DateField(null=True) employee_id = models.ForeignKey(Employee, null=True, on_delete= models.SET_NULL) tag_id = models.ForeignKey(Tag, null=True, on_delete= models.SET_NULL) subscriber_id = models.ManyToManyField(Subscriber) def __str__(self): return str(self.borrowing_id) in forms.py file class BorrowingForm(ModelForm): class Meta: model = Borrowing fields = ['end_date', 'employee_id', 'tag_id', 'subscriber_id'] in views.py def createBorrowing(request, pk): BorrowingFormSet = inlineformset_factory(Employee, Borrowing, fields=('end_date','tag_id','subscriber_id')) employee = Employee.objects.get(id=pk) formset = BorrowingFormSet(queryset=Borrowing.objects.none(), instance=employee) if request.method == 'POST': formset = BorrowingFormSet(request.POST, instance=employee) if formset.is_valid(): formset.save() return redirect('/login') context = {'formset':formset} return render(request, 'assetstracking/createBorrowing.html', context) -
How do I make a counter in Django that is displayed in the template?
Models.py class Coche(models.Model): matricula = models.CharField(max_length=7,primary_key=True) Views.py class Index(ListView): model = Coche total_coches = Coche.objects.filter(reserved=False, sold=False) Template <span class="text-primary">{{ total_coches.count }}</span> <span>coches disponibles</span></span> ### It does not show the number of cars my application has. Does anyone know what the fault is? ### -
Why am I getting error 404 in my django project when everything seems correct?
I have two apps in my Django project:basket and store. In root url files I configured the urls.py like this: from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('', include('store.urls', namespace='store')), path('basket/', include('basket.urls', namespace='basket')), store/urls.py: from django.urls import path from . import views app_name = 'store' urlpatterns = [ path('', views.all_products, name='all_products'), path('<slug:slug>/', views.product_detail, name='product_detail'), path('category/<slug:category_slug>/', views.category_list, name='category_list') ] basket/urls.py: from django.urls import path from . import views app_name = 'basket' urlpatterns = [ path('', views.basket_summary, name='basket_summary'), path('add/', views.basket_add, name='basket_add'), ] I am getting an error: Page not found(404) Request Method:GET Request URL:http://127.0.0.1:8000/basket/ Raised by:store.views.product_detail this is my store/views.py: from django.shortcuts import get_object_or_404, render from .models import * def product_detail(request, slug): product = get_object_or_404(Product, slug=slug, in_stock=True) context = { 'product': product, } return render(request, 'store/products/detail.html', context) please help me solve this problem i've been stuck on this for a long time. -
Can any tell me a way that can check whether a child has only two sponsorship and not more
language:- python framework :- django i have 3 model child sponsor sponsorship now I want to restrict sponsor to give sponsorship to particular child to 2. he can sponsor 1 as well as 2 . how can I restrict that -
Trying to perform addition operation on elements from rendered Django template
I've been working on this result management system, but I've been stuck on how to display total marks from the entered result. The results are entered from the Staff Panel and then each student has a view on their own page. The problem is how to add the student's result and also declare perform logic for grade declaration from the Student's panel for each course and display such result. Here is my models.py class Students(models.Model): id=models.AutoField(primary_key=True) admin = models.OneToOneField(CustomUser, on_delete=models.CASCADE) gender = models.CharField(max_length=255) profile_pic = models.FileField() address = models.TextField() department_id = models.ForeignKey(Department, on_delete=models.DO_NOTHING) session_year_id = models.ForeignKey(SessionYearModel, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now_add=True) StudentsView.py def student_view_result(request): student = Students.objects.get(admin=request.user.id) student_result = StudentResult.objects.filter(student_id=student.id) for row in student_result: exam_mark = row.course_exam_marks ca_mark = row.course_ca_marks total_mark = exam_mark + ca_mark context = { "student_result": student_result, 'total_mark':total_mark } return render(request, "student_template/student_view_result.html", context) my templates for rendering the result <div class="card-body"> <div class="table-responsive"> <table class="table"> <thead class="thead-light"> <tr> <th>ID</th> <th>Subject</th> <th>Continuous Assesment Marks</th> <th>Exam Marks</th> <th>Total Mark</th> <th>Grade</th> </tr> </thead> {% for row in student_result %} <tr> <td>{{ row.id }}</td> <td>{{ row.course_id.course_name }}</td> <td>{{ row.course_ca_marks }}</td> <td>{{ row.course_exam_marks }}</td> <td>{{ total_mark }}</td> <td> {% if total_mark >= 70 %} A {% elif total_mark >= 60 … -
All I do py manage.py migrate?
Traceback (most recent call last): File "C:\Users\DELL\Desktop\django\first_project\manage.py", line 11, in main from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\DELL\Desktop\django\first_project\manage.py", line 22, in main() File "C:\Users\DELL\Desktop\django\first_project\manage.py", line 13, in main raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?strong text -
Moving an app from a django project to another
I created a django project(prjct1) and has an app in it(app1) I also created another django project(prjct2) which also has an app(app2) How can I move app2 in prjct1 -
How to set Django Model ManyToManyField as none in django backend administation
The Likes Field Shows names of all Users. How to set it to None class Post(models.Model): title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts') updated_on = models.DateTimeField(auto_now= True) content = models.TextField() created_on = models.DateTimeField(auto_now_add=True) status = models.IntegerField(choices=STATUS, default=0) youtubeVideo = models.CharField(max_length=200, null=True, blank=True) category = models.ForeignKey(Category,on_delete=models.CASCADE, max_length=200, null=True,blank=True) image = models.ImageField(upload_to='images',null=True,blank=True) likes = models.ManyToManyField(User) def number_of_likes(self): return self.likes.count() class Meta: ordering = ['-created_on'] def __str__(self): return self.title -
I start a project to know more about google sign in and only add my app to my projects settings.py.Then i try to migrate, throws an error like
from django.utils import importlib ImportError: cannot import name 'importlib' from 'django.utils' -
Django auth views, problem at trying to change default reset email content?
Hello everyone i know there is a similar question to the one , as this thread shows How to customize django rest auth password reset email content/template. But unfurtunately even tho i followed the latest and the most upvoted answers i still didnt manage to succeed on changing the default email text and since that thread is based on older version i think it would be nice to have a patched up answer. So currently i am trying to access the default text by using the following serializer and trying to override the default one, from rest_auth.serializers import PasswordResetSerializer class CustomPasswordResetSerializer(PasswordResetSerializer): def get_email_options(self): return { 'subject_template_name': 'usuarios/password_reset_subject.txt', 'email_template_name': 'usuarios/password_reset_message.txt', 'extra_email_context': { 'pass_reset_obj': self.your_extra_reset_obj } } After that i created the templates and so on but i still get the default messages is worth noting i also followed brian ks old answer but that didnt work neither, would appreciate any help. -
Django - Pass int and None value to chart.js
I'm not really good in javascript, a language I always have difficulties to understand and work with. I'm working on a Django project where I need to pass a list to Chart.js to display a graph according to a specific Model. The problem I have is trying to pass a list to javascript from Django in order to display data if they are available or not. Let's say I have a python list from a Model attribute : [10, 20, None, 30, 40, None, 50] I need Chart.js to display data depending if they is a value for each axis point and nothing if they is None. When I try to pass the list with json.dump() and then in my template with {{ my_list|safe }} it display it like this : ['10', '20', 'None', '30', '40', 'None', '50'] Everything is diplayed as str when it should be either int or None/null value. How should I do if I need chart.js to have values as they are in backend ? Hoping my problem is clear enough, if not let me know and I'll try to better explain ! Thank you in advance for your precious help. -
Error Not Null Contriant Failed quiz_quiz.subject_id
I have this Table class Quiz(models.Model): quiz_title = models.CharField(max_length=300) num_questions = models.IntegerField(default=0) subject=models.ForeignKey(Subject,on_delete=models.CASCADE,blank=True,null=True) def __str__(self): return self.quiz_title And within this Table you can see I have subject foreign key Like when I create Quiz choose foreign key of subject in which subject I want to create Quiz class CreateQuizForm(forms.Form): quiz_name = forms.CharField(max_length=50, label="Quiz Name", widget=forms.TextInput(attrs={'class': 'quiz_name_box'})) num_questions = forms.IntegerField(label="Number of Questions", widget=forms.NumberInput(attrs={'class': 'num_questions_box'})) speed = forms.ModelChoiceField(queryset=Subject.objects.all()) def clean_name(self): data = self.cleaned_data['quiz_name'] # Check if quiz name is unique. if data == "Default_Name": raise ValidationError(_('Invalid name - Must be Unique')) # returns cleaned data return data this is My CreateQuizForm And when I choose Subject its showing Integrity Null contriantError -
spaces not getting printed in html
I have a django html template which has this form in it <form action="/image_info/" method="POST" id='image_form'> {% csrf_token %} <button class="imginfo" name='info_button' value={{x.desc}} type="submit">info</button> </form> The above form will POST the value to views.py whenever the submit button is pressed. but the problem is {{x.desc}} is a sentence and has blank spaces in it so only the first word is getting posted. I need the whole sentence. How should I do it. here x is a model and desc is its object. Thanks you. -
data send for covid tracker page /Django
I want the create a covid tracker page with Django.I created html frame with Bootstrap.I want get covid data and send to my page but I do not know how to do it. I get the data with request module but I don't know how to send to html.Can I write python code to the .html file? Note:I am sorry because my english is very poor therefore I got help from translate my html code: <div class="card-columns "> <div class="card bg-primary text-white"> <div class="card-body"> <p>Number of tests</p> </div> </div> <div class="card bg-danger"> <div class="card-body text-white"> <p>Cases</p> </div> </div> <div class="card bg-secondary"> <div class="card-body text-white"> <p>Deaths</p> </div> </div> <div class="card bg-warning"> <div class="card-body text-white"> <p>Lorem ipsum dolor sit amet consectetur.</p> </div> </div> <div class="card bg-success"> <div class="card-body text-white"> <p>Lorem ipsum dolor sit amet consectetur.</p> </div> </div> <div class="card bg-info"> <div class="card-body text-white"> <p>Lorem ipsum dolor sit amet consectetur.</p> </div> </div> </div> -
How to use Jinja with HTML carousel
I am working on my first Django project and I am trying to get Jinja code to properly align images on my index.html file. here is the code <!-- Start Banner Hero --> <div id="template-mo-zay-hero-carousel" class="carousel slide" data-bs-ride="carousel"> <ol class="carousel-indicators"> <li data-bs-target="#template-mo-zay-hero-carousel" data-bs-slide-to="0" class="active"></li> <li data-bs-target="#template-mo-zay-hero-carousel" data-bs-slide-to="1"></li> <li data-bs-target="#template-mo-zay-hero-carousel" data-bs-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="carousel-item active"> <div class="container"> <div class="row p-5"> {% for bnn in bnns %} <div class="mx-auto col-md-8 col-lg-6 order-lg-last"> <img class="img-fluid" src={{bnn.img.url}} alt=""> </div> <div class="col-lg-6 mb-0 d-flex align-items-center"> <div class="text-align-left align-self-center"> <h1 class="h1 text-success">{{bnn.title}}</h1> <h3 class="h2">{{bnn.subtitle}}</h3> <p>{{bnn.decs}} </p> </div> </div> </div> {% endfor %} </div> </div> <a class="carousel-control-prev text-decoration-none w-auto ps-3" href="#template-mo-zay-hero-carousel" role="button" data-bs-slide="prev"> <i class="fas fa-chevron-left"></i> </a> <a class="carousel-control-next text-decoration-none w-auto pe-3" href="#template-mo-zay-hero-carousel" role="button" data-bs-slide="next"> <i class="fas fa-chevron-right"></i> </a> </div> <!-- End Banner Hero --> I have tried the same format on other sections of the HTML page and they work fine. Here is an example: <!-- Start Categories of The Month --> <section class="container py-5"> <div class="row text-center pt-3"> <div class="col-lg-6 m-auto"> <h1 class="h1">Categories of The Month</h1> <p> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> </div> <div class="row"> {% for catg in … -
adding one serializer fields to another -django rest framework
my serializer.py file is as ... class RelativeSerializerSLC(serializers.ModelSerializer): full_name = serializers.CharField(source="user.full_name") rtl_full_name = serializers.CharField(source="user.rtl_full_name") gender = serializers.CharField(source="user.gender") phone = serializers.CharField(source="user.phone") email = serializers.CharField(source="user.email") avatar = serializers.CharField(source="user.avatar") date_of_birth = serializers.CharField(source="user.date_of_birth") class Meta: model = Relative fields = ("full_name", "rtl_full_name", "gender", "phone", "email", "avatar", "date_of_birth", "blood_group", "rel") read_only_fields = ["patient"] class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = "id", "full_name", "rtl_full_name", "gender", "phone", "email", "date_of_birth", "avatar" there i'm creating other serializer fields(userSerializer) and added to my RelativeSerializer. that seems uglyyy to me, i have no idea on. is there any better option like using one serializer fields for other. Thanks, new to DRF :) -
How to humanize measurement queries in Django
I have a distance query in Django and prints a distance with several decimal points. It displays distance in a measurement format as 1023.40258027906 m .I want to make this human readable. I tried using Decimal but this failed as it does not apply to Measurement objects. <style type="text/css"> ul{ list-style-type: circle; margin:0px; padding-left: 1em; } </style> <head> </head> <body><strong>Nearby Apartments</strong> {% if apartments %} <ul> {% for apartment in apartments %} <li> {{ apartment.apt_id }}: {{apartment.distance}} </li> {% endfor %} </ul> {% endif %} </div> </body> -
Django Channels group_send ~30s delay before sending
I'm trying to send two messages in succession from an AsyncJsonWebSocketConsumer to a group via group_send. My problem is that only one message to one client is delivered immediately, while the other messages are delivered roughly 30s later. If I only send one of the two messages, all messages are delivered immediately. I have set up a minimal example. The consumer sends back the message it received, but adds two timestamps server_received and server_sent when it receives and sends the message, respectively. class TestConsumer(AsyncJsonWebsocketConsumer): async def connect(self): await self.channel_layer.group_add('TESTGROUP', self.channel_name) await self.accept() async def receive_json(self, content): content['server_received'] = datetime.now().strftime('%H:%M:%S') await self.channel_layer.group_send('TESTGROUP', {'type': 'send_message', 'message': content}) # delayed only if sending two messages #await self.channel_layer.group_send('TESTGROUP', {'type': 'send_message', 'message': content}) async def send_message(self, event): await self.send_json({**event['message'], 'server_sent': datetime.now().strftime('%H:%M:%S')}) Here's some Javascript creating two connections and sending an initial message from the second websocket. (I know it's not super safe to do it this way, because we don't know in what state ws1 is, when sending, so we could drop a few messages, but doesn't matter for our purposes) function fmtDate(date) { return date.toLocaleTimeString('en-GB', {timeZone: 'UTC'}) } var ws1 = new WebSocket('ws://localhost:8000/test/') ws1.onmessage = (event) => { var msg = JSON.parse(event.data) const now … -
HTML displays duplicates of database entries
I'm having an issue with displaying my database entries in HTML. models.py: class Behandling(models.Model): title = models.CharField(max_length=100) description = models.CharField(max_length=200) time = models.IntegerField(default=60) price = models.IntegerField(default=995) views.py: def behandling(request): behandlingar = Behandling.objects.all() args = { 'behandlingar': behandlingar } return render(request, 'behandlingar.html', args) behandlingar.html <h2>{% for behandling in behandlingar %} {{ behandlingar.0.title }}</h2> <p>{{ behandlingar.0.description }}</p> {% endfor %} This is what displays in the html It seems like the title and description text repeats itself once for each item in the database. What could be wrong? -
Regarding Django error message TemplateDoesNotExist at /post/new
I'm learning djangou if anyone can help me when I want to create a new article I get this wrong. error TemplateDoesNotExist at /post/new/ blog/post_form.html Request Method: GET Request URL:http://127.0.0.1:8000/post/new/ Django Version: 3.1.7 Exception Type: TemplateDoesNotExist Exception Value: blog/post_form.html Exception Location: C:\Python39\lib\site-packages\django\template\loader.py, line 47, in select_template Python Executable: C:\Python39\python.exe Python Version: 3.9.2 Python Path: ['C:\\Users\\zakoo\\Desktop\\blogproject', 'C:\\Python39\\python39.zip', 'C:\\Python39\\DLLs', 'C:\\Python39\\lib', 'C:\\Python39', 'C:\\Python39\\lib\\site-packages'] this is sttings.py file sttings.py import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '*$=h-)vh383w^@02dus@xb73sdb78m%vpg=%8#vclb$mjw!y*b' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #local apps 'blog', 'accounts.apps.AccountsConfig', #3rd party 'crispy_forms',#new ] 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', ] ROOT_URLCONF = 'blogproject.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR,'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'blogproject.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { …