Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Integrate a multioption dropdown list in calculator Django
I will try to explain this issue the better I can. So built a calculator using django. The user can put the desired input, and then he sees all the results in a table, only by pressing the button: 'select'. Like this: However, now I want to add some more calculations by a dropdown list, and when the user selects this options, the output appears right away in the table.Like this: Here is my code: models.py class CalcAnalyzer(models.Model): sequence = models.TextField() gc_calc = models.CharField(max_length=2000000) person_of = models.ForeignKey(User,null=True,on_delete=models.CASCADE) def save(self, *args, **kwargs):# new if self.sequence != None: self.gc_calc = gc_calc(self.sequence) super(CalcAnalyzer,self).save(*args, **kwargs) def __str__(self): return self.sequence class addcalc_1(models.Model): name_sequence = models.ForeignKey(OligoAnalyzer, on_delete=models.SET_NULL, null=True) Option1_5 = models.FloatField(default=0) def save(self, *args, **kwargs): self.Option1_5 = Option1_5(self.sequence) class addcalc_3(models.Model): name_sequence = models.ForeignKey(OligoAnalyzer, on_delete=models.SET_NULL, null=True) optional_3 def save(self, *args, **kwargs): self.optional_3 = optional_3(self.sequence) views.py def calc_sequence(request): sequence_items=Calanalisis.objects.filter(person_of=request.user) form=AddSequenceForm(request.POST) if request.method=='POST': form=AddSequenceForm(request.POST) if form.is_valid(): profile=form.save(commit=False) profile.person_of = request.user profile.save() return redirect('calc_sequence') else: form=AddSequenceForm() myFilter=SequenceFilter(request.GET,queryset=sequence_items) sequence_items=myFilter.qs context = {'form':form,'sequence_items':sequence_items,'myFilter':myFilter} return render(request, 'Add_Calc.html', context) How can I insert this in the view.py? If the user selects the 5 or 3 box, the result should appear in the table bellow, if not, the result will stay the same. -
How to custom a search filter in django rest framework
Model class Student(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) first_name = models.CharField(verbose_name=_('first name'), max_length=20, blank=True, null=True) last_name =models.CharField(verbose_name=_('last name'), max_length=20, blank=True, null=True) class Bicycle(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) name = models.CharField(verbose_name=_('bicycle name'), max_length=20, blank=True, null=True) student_id = models.UUIDField(default=uuid4) View: class BicycleList(AdUpdateMixin, AdDestroyMixin, AdListMixin, AdCreateMixin, generics.GenericAPIView): permission_classes = [IsAuthenticated] queryset = Bicycle.objects.all() search_fields = ['name', 'id', 'first_name', 'last_name'] Now, I want create a custom search field in django rest framework. So that I can search first_name and last_name ? -
Django upload file to category name
I have such a task. There are two classes in the Model File, the first class is a category and the second class is a product. In the product class, you can select a category and you can upload a file, I need to do so which category I chose there will be uploaded the file, that is, if the category is called Document, the file will be uploaded to this folder. How to do it? -
Migrations are not made for all applications (some apps just skipped)
Django 3.2.6 Could you have a look at the picture. From themes downward are my apps. But when I make migrations, they are made only for articles. But when I make migrations for apps individually, migrations are made: Could you help me understand the reason of such behaviour and cope with this problem? -
How to connect to mysql database on aws in django?
I moved from php to django recently. I am trying to connect to Mysql database but its giving error django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'something.amazonaws.com' (timed out)") I used to connect to database in php like this public $default = array( 'datasource' => 'db', 'persistent' => false, 'host' => 'something.amazonaws.com', 'port'=> '', 'login' => 'username', 'password' => 'password', 'database' => 'mydatabase', 'prefix' => '', 'encoding' => 'utf8', ); setting.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mydatabase', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'something.amazonaws.com', } } -
I can't import dotenv from python-dotenv
Windows, Visual studio, django. I tried to install python-dotenv: https://pypi.org/project/python-dotenv/#getting-started. But when I want to import this command, I get error: Import "dotenv" could not be resolvedPylancereportMissingImports. I made such imports: (venv) PS C:\Users... pip3 install python-dotenv Requirement already satisfied: python-dotenv in c:\users...\venv\lib\site-packages (0.19.0). But import doesn't work. What can be wrong? -
Django SCSS, does not apply flex display
Hello I wanted to make a Django app but the problem is, app does not apply flex display. Rest of styles it applied. Any reason why Django ignores flexbox display or it is issue on SCSS side and i should have done it in pure css? html { font-size: 62.25%; box-sizing: border-box; } * { margin: 0; padding: 0; } *, *::before, *::after{ box-sizing: inherit; } .navbar{ color: pink; font-size: 5rem; display: flex; &__list{ display: flex; } &__item{ color:aqua; display: flex; } } .flex{ color: pink; } -
My datatable using js in django is very slow when i load more than 50000 rows
**My Model: ** class PartyMaster(models.Model): party_name = models.CharField(max_length=200,null=True, blank=True) email = models.EmailField(null=True, blank=True) contact = models.CharField(max_length=100,null=True, blank=True) address = models.CharField(max_length=350,null=True, blank=True) country = models.CharField(max_length=30,null=True, blank=True) sub_country = models.ForeignKey(CountryCategory,max_length=200,on_delete=models.CASCADE,null=True,blank=True,related_name='party_sub_country') state = models.CharField(max_length=50,null=True, blank=True) city = models.CharField(max_length=50,null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.party_name + " "+ self.email My View: In My Model there are around 50000+ rows def party_list(request): parties = PartyMaster.objects.all() context = { 'parties':parties, } return render(request,'party_master/party_edit.html',context) **My Template: ** {% extends 'base.html' %} {% block title %} Party List's {% endblock %} {% block body %} <div class="container"> <a href="{% url 'add_party' %}" class="btn btn-primary button_class mt-5">Party Master Form</a> <div class="py-3"> <div class="table-responsive"> <table class="table table-striped table-hover text-center table-responsive-sm" id="party_table"> <thead class="table-head"> <tr> <th scope="col">Party Name</th> <th scope="col">Email</th> <th scope="col">Contact</th> <th scope="col">Country</th> <th scope="col">Sub Country</th> </tr> </thead> <tbody> {% for party in parties %} <tr> <td class="pt-3">{{party.party_name}}</td> <td class="pt-3">{{party.email}}</td> <td class="pt-3">{{party.contact}}</td> <td class="pt-3">{{party.country}}</td> <td class="pt-3">{{party.sub_country.country_category}}</td> </tr> {% endfor %} </tbody> </table> </div> </div> </div> {% endblock %} {% block js %} <!-- Datatable --> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css"> <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script> <script> $(document).ready(function() { $('#party_table').DataTable( { dom: … -
Filter by django choices?
I want to filter by categories. But, it's not working. views.py def BytovyeTexnikiPylesosy(request): products = BytovyeTexniki.objects.filter(category='pylesosy') context = { 'products': products, } return render(request, 'store/product.html',context) models.py TEXNIKI = ( ('pylesosy','Пылесосы'), ('stiralki','Стиральные машины'), ('xolodilniki','Холодильники'), ) lass BytovyeTexniki(models.Model): name = models.CharField(max_length=200) category = models.CharField(max_length=300, choices=TEXNIKI) price = models.FloatField() image = models.ImageField(null=True, blank=True) def __str__(self): return self.name @property def imageURL(self): try: url = self.image.url except: url = '' return url I am trying to use this code. But, it's not working. I want to filter by category. Please help? -
Django url pattern is not a registered view function or pattern
I have a small Django web app, with multiple applications inside them. I have used the include in the urls.py files, but whenever I reference the URLs in the HTML files they don't load. Below are my 3 urls.py files. The one I'm having an issue will specifically is the nodes url pattern in the nodes urls.py #main urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('account/', include('account.urls')), ] #account urls.py from django.urls import path, include from django.contrib.auth import views as auth_views from . import views app_name = 'account' urlpatterns = [ path('login/', auth_views.LoginView.as_view(), name='login'), path('logout/', auth_views.LogoutView.as_view(), name='logout'), path('dashboard/', views.dashboard, name='dashboard'), path('nodes/', include('nodes.urls')), ] #nodes urls.py from django.urls import path from . import views app_name = 'nodes' urlpatterns = [ path('', views.nodes, name='nodes'), ] This is my HTML file where I am referencing the URL pattern: <li {% if section == 'nodes' %}class="active"{% endif %}> <a class="nav-link" href="{% url 'nodes' %}">Nodes</a> </li> Any help would be great, thanks -
django-machina search feature not working
I am using django-machina for creating forums. But the search feature provided by machina is not working. I have followed the docs. And have also updated the index as mentioned. But still the search is not working. I can't see any error in the log and there are no results. -
How do I add urls from a Django app module into my main urls.py?
Hi So I'm learning a course but it's a bit date on Django 1 and I'm using Django 3. (I'm a newbie so didn't realize the difference) In one section, it says in my accounts app to make a new module for passwords. Then to create an init.py file and an urls.py. I've done this and I"ve created very standard Urls for password reset and change. And have also included the new templates in my project root directory templates folder under registration. This is my urls. py in my accounts/passwords folder from django.urls import path from django.contrib.auth import views as auth_views app_name='accounts.passwords' urlpatterns = [ path('password/change/', auth_views.PasswordChangeView.as_view(), name='password_change'), path('password/change/done/', auth_views.PasswordChangeDoneView.as_view(), name='password_change_done'), path('password/reset/', auth_views.PasswordResetView.as_view(), name='password_reset'), path('password/reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'), path('password/reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('password/reset/complete/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), ] In my main urls.py I've added path('accounts/', include("accounts.passwords.urls")), When I try it out it says there is no reverse match for the name, etc Password_reset_done. When I put the urls/paths directly into my main urls.py it works. So I wanted to check, how do I include the urls from a module in an app? I gave the app_name as "accounts.passwords" and also added that as an app in the settings on my main. Just thought I'd … -
Google Enterprise Recaptcha scored base metrics not recording the request
I followed the Frontend integration javascript example and it is clearly working. I was able to assess the token in my django backend which I received from grecaptcha.enterprise.execute with an action login. But when I look at the metrics of that site key the request or any analysis is not captured. -
Getting dynamic argument values in inherited class - django
am using paho mqtt written a class class initializer(): def __init__(self): self.client = mqtt.Client(mqtt_server+str(int(time.time()))) self.client.username_pw_set( username=mqtt_username, password=mqtt_password) self.client.on_connect = self.on_connect self.client.on_subscribe = self.on_subscribe self.client.connect(broker, mqtt_port) self.client.loop_start() def on_connect(self, client, userdata, flags, rc): if rc == 0: #app_logger.info("Device Connection Established") print("Device Connection Established") else: #app_logger.info("Bad Connection") print("Bad Connection") def on_message(self, client, userdata, message): # app_logger.info(message.topic) print("message.topic", message.payload) then i have inherited this class to another class. class PublishData(initializer): def __init__(self): super(PublishData, self).__init__() self.client.on_message = self.on_message def on_message(self, client, userdata, message): print("message.payloa", message.payload) def begin(self, topic, data): self.client.on_message = self.on_message self.client.subscribe( "topic") self.client.publish( topic, str(data)) publishData = PublishData() publishData.begin(topic, data) iam getting message in on_message function in initializer class. but not getting that message in inherited class.how to get the message.payload value in publishdata class -
How to transfer value between Django and MQTT
I have a django graph that will display some random value. I had subscribe to my mqtt topic and integrated into my django application. But the problem is how can I read the msg.payload in my views.py? I want my graph to show the value that published from MQTT. For your information, I create a py file to store my MQTT connection and loop it in my init.py. Views.py from django.shortcuts import render import random from paho.mqtt import client as mqtt_client def showdata(request): context = '''Here is where i need to put the (MQTT VALUE: msg.payload )''' return render(request, 'index.html', {'data': context}) MQTT.py import paho.mqtt.client as mqtt global test # The callback for when the client receives a CONNACK response from the server. def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) # Subscribing in on_connect() means that if we lose the connection and # reconnect then subscriptions will be renewed. client.subscribe("Wind") # The callback for when a PUBLISH message is received from the server. def on_message(client, userdata, msg): print(msg.topic+" "+str(msg.payload)) test = msg.payload client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect("localhost", 1883, 60) Init .py from . import mqtt mqtt.client.loop_start() -
Communicating between two user's webpages
Let's say you have two users A and B logged into a website. I want user A to be able to trigger an action to automatically display certain web pages on user B's screen (either displaying new web content on the same page or re-directing the customer to a different page) - some sort of inter-website communication. I'm a novice developer so have absolutely no idea as to how to approach this. Would sincerely appreciate any possible solution (something that works with Python & Django or React & JS is preferable, if possible)!! Cheers! -
Is it possible to add dependent text and date field under a checkbox or a dropdown in django models
I want to know if I can directly make text and date fileds appear or connect when a dropdown (or a choice field) or a checkbox (boolean filed) is selected in django models. I know this can be done from the front end with javascript but i don't want to do it from the front end creating input fileds and use javascript to submit data. I have many fileds and if can do it directly from the django admin site then it reduces my burden. I am sharing only the part of the model that I want to act as mentioned above: models.py citation_type = ( ('SCC', 'SCC'), ('AIR', 'AIR'), ('AIOL', 'AIOL'), ('MLJ', 'MLJ'), ('Scale', 'Scale'), ('Supreme', 'Supreme'), ('A11CJ', 'A11CJ'), ('SCC(L&S)', 'SCC(L&S)'), ('FLR', 'FLR'), ('MhLJ', 'MhLJ') ) class Laws(models.Model): citations = models.Charfield(max_length = 255, choices= citation_type ,null=True) Now here I want that if someone for example chooses 'SCC' from the dropdown then one charfield and datefield related to SCC should appear that stores the data with to SCC. So when I dsiplay it in a html it should look like " citations: SCC (data in charfield)(data in data field) ". If it is not possilble with dropdowns even check boxes … -
Problem In Send Parameters of View to Lib
I have a problem for define def in Django. this is My View.py import logging from django.shortcuts import redirect from django.urls import reverse from django.views.generic import ListView from .models import Saham_Status, Saham_Pay from azbankgateways import bankfactories, models as bank_models, default_settings as settings from django.http import HttpResponse, Http404 from .forms import Saham_Pays from time import gmtime, strftime class SahamSta_ListView(ListView): template_name = 'forms/display_forms.html' context_object_name = 'saham_st' model = Saham_Status def get_queryset(self): return self.model.object.all().filter(user_name=self.request.user) def get_context_data(self, **kwargs): context = super(SahamSta_ListView, self).get_context_data(**kwargs) context['form'] = Saham_Pays return context class Sta_Pay_ListView(ListView): template_name = 'forms/statuse_pay.html' context_object_name = 'sta_pay' model = Saham_Pay def get_queryset(self): return self.model.objects.all().filter(user_name=self.request.user) def get_context_data(self, **kwargs): context = super(Sta_Pay_ListView, self).get_context_data(**kwargs) context['form'] = Saham_Pays return context #this part def get_payid(): pay_id = Saham_Status.object.all().filter(saham_pay_id=) return pay_id Now this is Lib in Django Lib for send parameters(p.py): def get_pay_data(self): data = { 'terminalId': int(self._terminal_code), 'userName': self._username, 'userPassword': self._password, 'orderId': int(self.get_tracking_code()), 'amount': int(self.get_gateway_amount()), 'localDate': self._get_current_date(), 'localTime': self._get_current_time(), 'additionalData': description, 'callBackUrl': self._get_gateway_callback_url(), 'payerId': get_payid() } return data and this models.py: class Saham_Status(models.Model): user_name = models.ForeignKey(User, on_delete=models.CASCADE) saham_pay_id = models.CharField(max_length=15, default=None) I want to send a parameter(saham_pay_id = field in db) of database that user login to p.py('payerId': get_payid()) and this function get_payid() defined in views.py. Help Me. -
Django forms.SelectMultiple ERROR: Select a valid choice. ['Internet bandwith'] is not one of the available choices
I am trying to implement my own form through a model that I have created, for some reason Django does not validate my form and it is related with forms.SelectMultiple (expense_category and expense_type) but none of the similar questions posted on SO could solve my problem. Basically I want a Select multiple (but allow only one selection). Code: forms.py: from django.forms import ModelForm from django import forms from expense.models import Expense class ExpenseForm(ModelForm): class Meta: model = Expense fields = ['project', 'contents', 'amount', 'currency', 'expense_date', 'store_company_client_name', 'expense_category', 'expense_type', 'note'] widgets = { 'project': forms.TextInput( attrs={ 'class': 'form-control' } ), 'contents': forms.TextInput( attrs={ 'class': 'form-control' } ), 'amount': forms.NumberInput( attrs={ 'class': 'form-control' } ), 'currency': forms.Select( attrs={ 'class': 'form-control', } ), 'expense_date': forms.TextInput( attrs={ 'class': 'form-control form-control-sm datetimepicker-input', 'style': 'font-size:14px;', 'name': 'month', 'placeholder': 'Select month', 'data-target': '#monthDatetimepicker' } ), 'store_company_client_name': forms.TextInput( attrs={ 'class': 'form-control' } ), 'expense_category': forms.SelectMultiple( attrs={ 'class': 'form-control' } ), 'expense_type': forms.SelectMultiple( attrs={ 'class': 'form-control' } ), 'note': forms.Textarea( attrs={ 'class': 'form-control', 'rows': '8' } ), } new_expense.html: <div class=" " style="font-size:14px;" > <div class="m-auto w-50"> <!-- modelform --> <div class="container"> <form method="POST"> {% csrf_token %} <!-- TIPS # --> <div class="d-flex flex-row "> <div class="d-flex w-25 p-1 … -
Arranging models fields according to our wish in django admin panel
Can I arrange this models according to my needs in Django admin panel dashboard. Now this is in alphabetical order , but I want to make my own arrangements. Can anybody help me how can I make that. Thank you. Please click this link below for the image. Django admin dashboard. -
my order items and order is being saved in the admin django , but is not been shown in the cart template, and quantity is not been updated to 3nos
Here, I am trying to add a product to the cart. But i am facing some issues. Firstly, the objects are not being rendered to the cart template which i want to add to cart, but in the admin django, the products can be seen there. However, the quantity of the product is not incrementing by itself. Two same products get added with nos 1, 2. however, when i try to add the same product thrice, then duplicacy happens of the 2nd added product .U can see the screenshot below : views.py: @login_required def add_to_cart(request, uid): item = AffProduct.objects.get(uid=uid) try: order_item = OrderItem.objects.create( item=item, user=request.user, ordered=False ) except: order_item = None order_qs = Order.objects.filter(user=request.user, ordered=False) if order_qs.exists(): order = order_qs[0] # check if the order item is in the order if order.items.filter(item__uid=item.uid).exists(): order_item.quantity = order_item.quantity + 1 order_item.save() print(order_item) messages.info(request, "This item quantity was updated.") return redirect("cart") else: order.items.add(order_item) print(order_item) messages.info(request, "This item was added to your cart.") return redirect("cart") else: ordered_date = timezone.now() order = Order.objects.create( user=request.user, ordered_date=ordered_date) order.items.create(order_item) print(order_item) messages.info(request, "This item was added to your cart.") return redirect("cart") models.py class OrderItem(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) ordered = models.BooleanField(default=False) item = models.ForeignKey(AffProduct, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) def __str__(self): … -
Django admin template bug
Today I installed django==3.2.6 LTS for a new project, but I faced this template of admin. Is is correct or it's a bug? -
Make foreign key editable in your formset
I'm really struggling with django-forms. In particular, I'd like to have a formset of my OrderMedia model, where the foreignkey to contactMethod is also editable (a form). Models.py: class OrderMedia(models.Model): CHOICES = ( ('IDB', _('IDB')), ('E', _('E')), ) contactMethod = models.ForeignKey('BusinessContactMethod', on_delete=models.CASCADE) publication = models.BooleanField(default=True) management = MultiSelectField(choices=CHOICES, blank=True) to_create = models.BooleanField(default=False) from_order = models.ForeignKey('Order', on_delete=models.CASCADE) class BusinessContactMethod(models.Model): medium = models.ForeignKey(ContactMedium, on_delete=models.CASCADE) value = models.CharField(max_length=100, blank=True, null=True) active = models.BooleanField(default=True) Views.py: class NewOrderPart2(View): form_class = OrderForm template_name = 'orders/new_order_part2.html' def get(self, request, *args, **kwargs): est_number = self.kwargs['est_number'] order = Order.objects.get(est_number=est_number) MediumFormset = inlineformset_factory(Order, OrderMedia, exclude=[''], extra=1, can_delete=True) mediums = MediumFormset(instance=order) form = self.form_class(instance=order) return render(request, self.template_name,{ 'form': form, 'mediums': mediums, }) def post(self, request, *args, **kwargs): est_number = self.kwargs['est_number'] order = Order.objects.get(est_number=est_number) MediumFormset = inlineformset_factory(Order, OrderMedia, exclude=[''], extra=1, can_delete=True) mediums = MediumFormset(request.POST, instance=order) form = self.form_class(request.POST, instance=order) if mediums.is_valid(): mediums.save() print(mediums) if form.is_valid(): form.save() return HttpResponseRedirect(f'/order/{est_number}') return render(request, self.template_name, { 'form': form, 'mediums': mediums, }) Forms.py: class OrderForm(forms.ModelForm): class Meta: model = Order fields = '__all__' widgets = { 'order_start': DateInput, 'order_end': DateInput, 'order_publication': DateInput, 'contact_signed_date': DateInput, } Template: <form method="POST"> <div id="form_set"> {% for form in mediums.forms %} <div class='custom-select'> {{form }} <div> {% endfor %} </div> </form> I've … -
AWS EC2 instance Django project
my website is not connecting to was ec2 instance 2:nginx also not giving any error 3: gunicorn giving no error security group, port allowed HTTP and https -
AttributeError at /blog/create/blog-post
I am learning django but this error has made me sick. I wanted to create a form to register a new blog post. But I get this weird error nobody seems to have got. I'm really a begginer in django. Here's the trace: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/blog/create/blog-post Django Version: 3.2.6 Python Version: 3.9.6 Installed Applications: ['blog', 'django_summernote', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed 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'] Traceback (most recent call last): File "C:\My_Stuff\Blogistan\env\lib\site- packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\My_Stuff\Blogistan\env\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\My_Stuff\Blogistan\blog\views.py", line 19, in BlogPostForm form = BlogPostForm(request.POST or None) File "C:\My_Stuff\Blogistan\blog\views.py", line 19, in BlogPostForm form = BlogPostForm(request.POST or None) Exception Type: AttributeError at /blog/create/blog-post Exception Value: 'NoneType' object has no attribute 'POST' Here's my console: Internal Server Error: /blog/create/blog-post Traceback (most recent call last): File "C:\My_Stuff\Blogistan\env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\My_Stuff\Blogistan\env\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\My_Stuff\Blogistan\blog\views.py", line 19, in BlogPostForm form = BlogPostForm(request.POST) File "C:\My_Stuff\Blogistan\blog\views.py", line 19, in BlogPostForm form = BlogPostForm(request.POST) AttributeError: 'QueryDict' object has no attribute 'POST' My views.py: def BlogPostForm(request): form = BlogPostForm(request.POST) …