Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Send messages asynchronously using Django Channels as they are generated
I've a process that receives data asynchronously using httpx, and I would like to send this data as soon as it is received. Instead Channels only sends it once all the data is received. Not sure if there is something basic I've misunderstood but I'd have thought this would be bread and butter functionality for an asynchronous framework. I'm using channels in memory layer, and don't have the option to install Redis server, besides based on other questions on stackoverflow - I'm not sure if that would help anyways. Minimal example: class AsyncSend(AsyncJsonWebsocketConsumer): async def connect(self): # Join group self.group_name = f"test" await self.channel_layer.group_add( self.group_name, self.channel_name ) await self.accept() #Replicate non blocking call async for result in self.non_block(): await self.send_task(result) async def non_block(self): for integer in range(4): await asyncio.sleep(1) curTime = datetime.now().strftime("%H:%M:%S") print(f"{curTime} - {integer}") yield integer async def send_task(self, result): curTime = datetime.now().strftime("%H:%M:%S") print(f"{curTime} - Send task called") await self.channel_layer.group_send( self.group_name, { 'type': "transmit", 'message': result, } ) print("Finished sending") async def transmit(self, event): print(f"Received event to transmit...") async def disconnect(self, close_code): # Leave group await self.channel_layer.group_discard( self.group_name, self.channel_name ) Output: 10:23:21 - 0 10:23:21 - Send task called Finished sending 10:23:22 - 1 10:23:22 - Send task called … -
Django select2 does not appear
I try to add the Select2 in my django app but i can't use it. When I click on the box to perform the search does not appear so it does not work. Does anyone have a solution so that i can use it in my app ? ======== Page.html ======== {% load static %} <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}"> <title>THE PAGE</title> </head> <link rel="icon" type="image/x-icon" href="{% static 'images/icons10.png' %}"> <body> {% include 'accounts/navbar.html' %} <div class="container-fluid"> {% block content %} {% endblock %} </div> <hr> <!-- jQuery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- Select2 --> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"> </script> <script> $(document).ready(function() { $('#id_employe').select2(); }); </script> <!-- Footer --> <footer class="page-footer font-small blue"> <!-- Copyright --> <div class="footer-copyright text-center py-3">© {% now "Y" %} <h7>PAGE</h7> </div> </footer> <!-- Footer --> </body> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> </html> This is the page of the form. ============ The page of form.html ========= {% extends 'accounts/page.html' %} {% load crispy_forms_tags %} {% load static %} {% block content %} <br> <h3>ADD … -
Upload to Heroku - ProgrammingError: relation does not exist
I deployed my application to Heroku, but I am not able to add any data. When I tried to open first table with data from model I received this error message: ProgrammingError at /category/category_table relation "tables_category" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "tables_category" And when I tried to add first data I received this error message: ProgrammingError at /admin/tables/category/add/ relation "tables_category" does not exist LINE 1: INSERT INTO "tables_category" ("category_name") VALUES ('sho... I went through similar Q/A here, but they do not solve my issue, as I have: a) deleted all migration files from my local disk, then b) I run: python3 manage.py makemigrations c) I run: heroku run python3 manage.py migrate So all should be up to date and I have this log from Heroku: Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, tables Running migrations: No migrations to apply. So currently do not know what to do. Maybe the problem is that I completely deleted file with migrations, because now I tried to change one my model and when I tried makemigrations and migrate, answer was no migrations to apply. So I copied file __init__.py to migrations file and no makemigration is … -
How to navigate through multiple pages from search in Django?
I am trying to create a webpage using Django where my database consists thousands of CVEs and display the list of CVEs based on what I typed in the search bar. So far, the search function is working perfectly and it displays the paginated results. But when I try to navigate to next page, it will show a blank page. Below is the code of my views.py and template. views.py def search_cve(request): if request.method == 'GET': searched = request.GET.get('searched') if searched: cve_search = BDSA.objects.filter(cve_id__icontains=searched) paginator = Paginator(cve_search.order_by('-cve_id'), 10) # show 10 per page try: page = int(request.GET.get('page', '1')) except: page = 1 try: cves = paginator.page(page) except: cves = paginator.page(1) index = cves.number - 1 max_index = len(paginator.page_range) start_index = index - 2 if index >= 2 else 0 end_index = index + 2 if index <= max_index - 2 else max_index page_range = list(paginator.page_range)[start_index:end_index] return render(request, 'QueryService/search_cve.html', {'searched':searched, 'cve_search':cve_search, 'cves': cves, 'page_range': page_range}) else: return render(request, 'QueryService/search_cve.html', {}) template <body> {% block content %} <br/> <center> <h1>Searched for: {{ searched }}</h1> <br/> <div class="container"> <table class="table table-hover table-striped table-bordered"> {% for cve in cves %} <tr> <td><a href="{% url 'show-cve' cve.cve_id %}">{{ cve }}</a></td> </tr> {% endfor %} </table> … -
How to setup multiple django projects to access the same database and models
I have one django project that serves as an API and contains a database and multiple apps with models, database migrations and so on. I want to have a custom admin interface as well as django-admin which are only accessible via the intranet. Is this possible within the same django project while the other apps are accessible from outside the intranet? And if not, is it possible to have two django projects. One which serves as the API containing the database, models and migrations. And another one that contains just the django-admin and my custom admin interface app that can access the databse and models from the other project? -
Getting anonymous user after login through otp
I am trying to authenticate the user through only otp and without password. After user enters his/her email, an otp will be sent to that email. After login, the user has several page links to go to and I want that user to stay logged in for those pages. The homepage after login is receiving the user details but not after the user goes to any other page. For eg., if the user clicks on Add Owner after logging in, request.user returns AnonmousUser. models.py class S_Society_Association_Master(models.Model): society = models.ForeignKey(S_Society_Master, default=0, on_delete=models.CASCADE) member_name = models.CharField(verbose_name = "Member Name", max_length=100) member_contact_number = models.CharField(verbose_name="Phone Number", max_length=15) otp = models.CharField(max_length=6, blank=False, default=0) # For HOTP Verification member_role = models.CharField(verbose_name="Member's Role", max_length=100, choices=[("P", "President"), ("T", "Treasurer"), ("S", "Secretary"), ("EC", "EC members"), ("O", "Other members")]) member_email_id = models.EmailField(verbose_name = "Member's Email", max_length=100) member_from_date = models.DateField(verbose_name = "Member From", auto_now_add=True) last_login = models.DateTimeField(verbose_name="Last Login", auto_now = True) member_to_date = models.DateField(verbose_name="Member To") deld_in_src_ind = models.CharField(max_length=20, choices=[("yes", "Yes"), ("no", "No")], blank=True, null=True) created_date = models.DateField(verbose_name = "Created Date", auto_now_add = True, blank=True, null=True) created_by = models.ForeignKey(User, to_field='id', related_name = "assoc_created_by", on_delete = models.SET_NULL, verbose_name="Created By", max_length=100, blank=True, null=True, default=None) last_updated_date = models.DateField(verbose_name = "Updated Date", auto_now = True, blank=True, … -
ModuleNotFoundError: No module named 'django.forms.util'
I have a django model class which have a field of 'amount' I used pip install django-moneyfield install money field but I got an error when I run migration My Code: class Student(models.Model): user = models.ForeignKey(CustomUser, on_delete = models.CASCADE) fee = MoneyField(decimal_places = 2, max_digits = 8, amount_default = Decimal("0"), currency_default = "INR", null = True, blank = True) Error -
how to send download link via mail in django
i want to send a download link via email using django.Any suggestions i already done some methods but didn't work body = 'Hello MR THIS MESSAGE FORM RECURITMENT APP The Persons You are looking for is Just Found.The Lists are given below : \n {0} {1} {2}'.format( ' '.join(str(name) for name in name_list), ' \n' , ' '.join(str(em) for em in email_list) ) + reverse('i.resume.path') message = EmailMessage("hello" , body,"********@gmail.com" , ['********@gmail.com'],['*******@gmail.com']) message.attach('data.csv', csvfile.getvalue(),'text/csv') message.send() the code for sending mail -
status update using Django
I am bigginer to learn Django and create a one Phototgrapher Website and I want add category status to user easily activate and deactivate category status how can I do this can any one help for this. I am not using Django admin panel I create Photographer Admin panel -
Deployment preview with ephemeral PostgreSQL
My architecture currently consists of a webapp built with Django and Webpack and deployed on Cloud Run. The build process consists of just a Dockerfile. When someone from my team opens a new PR, we would like for deployment to commence automatically to a new instance. This is explained here (deployment previews). However, I would like for an ephemeral database to also be spawn - similarly to what happens in Heroku. This is necessary because otherwise conflicting Django's migrations may damage Stage's database (e.g., both me and a teammate pushing two conflicting migrations). -
UpdateIssueForm.__init__() missing 1 required keyword-only argument: 'pk'
I tried making an update view using class-based views. I have not known how to pass this kwarg to the view. I have ended up with an error. Here is the view and the form View class UpdateTeacherIssueView(LoginRequiredMixin,UpdateView): model = TeacherIssue form_class = UpdateTeacherIssueForm template_name = 'crud_forms/edit_teacher_issue.html' success_url = reverse_lazy('view_student') #To be changed def get_form_kwargs(self): kwargs = super(UpdateTeacherIssueView, self).get_form_kwargs() kwargs['school'] = self.request.user.school kwargs['issuer'] = self.request.user #kwargs['pk'] = self.request.id return kwargs The form class UpdateTeacherIssueForm(forms.ModelForm): """Edit TeacherIssue Form""" def __init__(self,*args, pk, school,issuer, **kwargs): super(TeacherIssueForm, self).__init__(*args, **kwargs) self.fields['issuer'].initial = issuer self.fields['book_id'].queryset = Books.objects.filter(school=school,no_of_books=1).select_related('subject') self.fields['borrower_teacher'].initial = pk class Meta: model = TeacherIssue fields = ['issuer','book_id','borrower_teacher','issue_date'] widgets = { 'borrower_teacher':forms.TextInput(attrs={"class":'form-control','type':'hidden'}), "issue_date":forms.TextInput(attrs={"class":"form-control"}), 'issuer':forms.TextInput(attrs={"class":'form-control','type':'hidden'}), 'book_id':Select2Widget(attrs={'data-placeholder': 'Select Book','data-width': '100%'},) } -
Continue request django rest framework
I have a request that lasts more than 3 minutes, I want the request to be sent and immediately give the answer 200 and after the end of the work - give the result -
How to create form with multiple records?
I have a model Product with a name of product and a model ProductCosts with a cost value which is connected to the Product model. I have currently a form for input of new product and another form for input of costs, where I can select product and add costs to this new product. And is there some way how to create a form which will show product names which are missing costs in one column and in the second column blank fields for input of product costs and there will be x rows based on number of products which are currently without costs? (There is also another filed with number of produced products in ProductCosts, but I ignored it to simplify my question.) My models.py: class Product(models.Model): name = models.CharField("Product", max_length=150) ... class ProductCosts(models.Model): product = models.OneToOneField(Product, on_delete=models.CASCADE) costs = models.DecimalField("Costs", max_digits=10, decimal_places=2) produced = models.IntegerField("Produced", null=True, blank=True) ... form.py class ProductCostsForm(ModelForm): class Meta: model = models.ProductCosts fields = ["product", "costs", "produced"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Div( Div("product", css_class="col-12"), css_class="row", ), Div( Div("costs", css_class="col-6"), Div("produced", css_class="col-6"), css_class="row", ), Div( Div(HTML('<hr>'), css_class="col-12"), css_class="row", ), ) self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Submit', css_class="col-4 btn … -
django template set all columns of a table at the same size
here is my templates, and what they display : template.html <div class="card"> <div class="card-body p-0"> <table class="table" style="width: 100%;"> <tbody> <tr> {% for field in fields %} {% if field != "rehabilitation" and field != "operation_type" and field != "subvention" and field != "history" %} {% if field|is_sortable == False %} <th bgcolor="gray" style="color: white; width: 5%">{{ field }}</th> {% elif field != "related_projects" and field != "history" %} <th bgcolor="gray" style="color: white; width: 5%"> <a href="?order_by={{ field }}" style="color: white">{{ field }}</a> {% include 'projects/functionalities/filter.html' %} </th> {% endif %} {% endif %} {% endfor %} </tr> <tr> <td>hey</td> <td>helllooooooo</td> <td>hello how are you ?</td> <td>yo</td> <td>teeeest</td> <td>aaa</td> <td>bbb</td> <td>cccccccccccccccccc</td> <td>wow</td> <td>testestestest</td> <td>test test test test</td> <td>i'm testing this</td> <td>whyyy does this don't work</td> <td>hello</td> <td>hey</td> <td>hey</td> </tr> </tbody> </table> </div> </div> filter.html <form class="d-flex flex-column bd-highlight mb-5" method="GET" action="{% url 'project-list' %}"> {% csrf_token %} <div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="search"> <div class="input-group-btn"> <button class="btn btn-success" type="submit"></button> </div> </div> </form> and here is what I have on my screen : As you can see, all the columns have a different size depending on what is written inside, and it makes my text input zones ugly. I would … -
foreign key serializer django rest framework
i have here small issue i just wanna return foreign key data using DRF my modles: class Trade(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) partsNum = models.IntegerField(null=True) class TradePart(models.Model): mainTrade = models.ForeignKey(Trade, models.CASCADE, null=True) data = models.JSONField() my serializers.py: class TradePartsSerializer(serializers.ModelSerializer): class Meta: model = TradePart fields = '__all__' class TradeSerializer(serializers.ModelSerializer): tradepart = TradePartsSerializer() class Meta: model = Trade fields = ['user', 'partsNum', 'tradepart'] my views.py if 'user' in request.query_params: userId = request.query_params['user'] user = User.objects.get(id=userId) trades = Trade.objects.filter(user=user) serializer = TradeSerializer(trades, many=True) return Response({'trades': serializer.data}, status=200) it shows this error: "'Trade' object has no attribute 'tradepart'" how can i fix this? i wanna return response including trade + tradepart for each trade -
Autofill foreign key field based on the slug in the URL
I'm working on a forum website where the user selects the game that they want to post about and writes the post. The problem is I don't want the user to select the game from the drop-down foreign key field. I want the foreign key field to populate itself based on the slug provided in the URL. models.py posts app class Post(models.Model): title = models.CharField(max_length=200, blank=True, null=True) user = models.ForeignKey(User, related_name="posts",on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now=True) message = models.TextField() # need this field automatically filled out game = models.ForeignKey(Game, related_name="posts",null=True, blank=True,on_delete=models.CASCADE) slug = models.SlugField(allow_unicode=True, unique=False, null=True, blank=True) def __str__(self): return self.title def save(self, *args, **kwargs): self.slug = slugify(self.title) super().save(*args, **kwargs) def get_absolute_url(self): return reverse( "posts:single", kwargs={ "username": self.user.username, "pk": self.pk, "slug": self.game.slug, } ) models.py games app class Game(models.Model): title = models.CharField(max_length=255) slug = models.SlugField(allow_unicode=True, unique=True) def __str__(self): return self.title def save(self, *args, **kwargs): self.slug = slugify(self.title) super().save(*args, **kwargs) def get_absolute_url(self): return reverse("games:single", kwargs={"slug": self.slug}) urls.py posts app urlpatterns = [ path('', views.PostList.as_view(), name="all"), # need this slug to match the game path("new/<slug>/", views.CreatePost.as_view(), name="create"), ] views.py posts app class CreatePost(LoginRequiredMixin, SelectRelatedMixin, generic.CreateView): fields = ('title','message','game') model = models.Post select_related = ('user', 'game') I'm guessing I need to grab the game object … -
DEBUG Django variable in production mode stays True [closed]
in my Django project in production mode, I always see debug messages. Yet the DEBUG debug variable stays true but in my code it's DEBUG=FALSE -
Is there a way to use {% block content %} where it only displays on certain @media's?
I'm currently doing a coding course and learning about block content and designing a website using django and bootstrap. I've got some code in a seperate HTML page that I'm inserting into other HTML pages using {% block content %} {% include 'html page' %}. I was wondering if there was a way within the {% -- %} or maybe a CSS @media style where the block content only shows on certain devices? Thanks! -
Django modelformset_factory widget validation
I'm having trouble understanding how form/model field validation works in Django 4.1.1. I want to use the models.CharField in my model with the stores = models.CharField(validators=[validate_comma_separated_integer_list], max_length=255) however when inputting and posting my formset no validation is carried out like it would be if I used models.EmailField and forms.EmailInput in the form/widget. I'm probably not understanding something properly but can't for the life of me work it out. Hopefully someone can point me in the right direction. Be as harsh as you like. forms.py - ServerFormSet = modelformset_factory( RequestServersStores, fields=("server_number", "store_numbers"), extra=1, validate_max=True, validate_min=True, labels={ 'server_number': 'Server Number', 'store_numbers': 'Store Numbers' }, widgets={ 'server_number': forms.Select( choices=server_choices ), 'store_numbers': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'comma separated list of store numbers e.g. 7,15,29' } ) }) views.py - ... elif request.method == 'POST': create_request = CreateUserForm(request.POST) server_formset = ServerFormSet(request.POST) if create_request.is_valid() and server_formset.is_valid(): request = create_request.save() for form in server_formset: server = form.save(commit=False) server.request = request server.save() models.py - class RequestServersStores(models.Model): objects = models.manager server_number = models.CharField(max_length=6) store_numbers = models.CharField(validators=[validate_comma_separated_integer_list], max_length=255) request = models.ForeignKey( CreateUserRequest, related_name='servers', on_delete=models.SET_NULL, null=True ) -
How can i ignore a many to many field in a Model. Because i cannot set to cache
I have a model that contains many to many field but in some code this model needs to be cached. but when i call the cache.set(model) django raises exception PicklingError: Can't pickle <class 'django.db.models.fields.related_descriptors.RelatedManager'>: attribute lookup django.db.models.fields.related_descriptors.RelatedManager failed i am using django 1.1 and python 2.7 -
Django: select columns across apps with the same foreign key
This is a follow-up question of this. I have app1/models.py: class A(models.Model): id = models.IntegerField(primary_key=True) text = models.CharField(max_length=20) class B(models.Model): fid = models.ForeignKey(A, models.CASCADE) text = models.CharField(max_length=20) class C(models.Model): fid = models.ForeignKey(A, models.CASCADE) text = models.CharField(max_length=20) and app2/models.py: from app1.models import A class D(models.Model): fid = models.ForeignKey(A, models.CASCADE) text = models.CharField(max_length=20) I wish to get A.text B.text C.text D.text where A.id == B.fid == C.fid == D.fid == 1. From the referred question, I was able to retrieve the first 3 columns using: B.objects.filter(fid=1).values('text', 'fid__text', 'fid__c__text') # B.text, A.text, C.text However I cannot get D.text using this query. I know I can do a filter on D and give it a manual calculation, but I'm looking forward to a more Djangoic way. (In case of a multi-match, product the rows, so if there are 2 rows in B that matches the given fid and 3, 4 for C, D, a total of 24 rows in returned.) -
access django channels' consumer class variables from outside
class ExampleConsumer(AsyncWebsocketConsumer): async def connect(self): self.id = 1 self.foo = 'bar' await self.accept() Is it possible to get all existing instances of ExampleConsumer, filter them by id and get foo value? Somewhere in a django view -
I want to show products by category using the . feature (.filter)
I am a beginner to Django, I want to show products by category using the .feature (.filter), I tried many times but I couldn't do it I hope someone can help me. Please write the code with explanation MODELS: from django.db import models # Create your models here. class Category(models.Model): name = models.CharField(max_length=200) slug = models.CharField(max_length=200) def __str__(self): return self.name class Product(models.Model): Category = models.ForeignKey(Category, on_delete=models.CASCADE) name = models.CharField(max_length=200, null=False, blank=False) slug = models.CharField(max_length=200, null=False, blank=False) description = models.TextField(max_length=350, null=False, blank=False) image = models.ImageField( null=False, blank=False) quantity = models.IntegerField(null=False, blank=False) def __str__(self): return self.name URLS: from django.urls import path from . import views urlpatterns = [ path('', views.home, name="home"), path('f/<str:slug>', views.fd, name="fd"), path('category', views.category, name="category"), path('category/<str:slug>', views.categoryslug, name="categoryslug"), ] VIEWS: def home(request): context = { 'Pr': Product.objects.all(), } return render(request, 'pages/home.html', context) def fd(request, slug): context = { 'gfd' : Product.objects.get(slug=slug), } return render(request, 'pages/product.html', context) def category(request): context = { 'Categorys': Category.objects.all(), } return render(request, 'pages/category.html', context) Please write the code with explanation i need to show product by category -
how to get book_title written by author_name in for loop
how to get book name which is related author, i want author name in first column and book name in 2nd column, by querying authors.objects.all() i got author name buy i want book name which related to that author. models.py class Author(models.Model): author_name = models.CharField(max_length = 100) def __str__(self): return self.author_name class Book(models.Model): book_title = models.CharField(max_length = 100) desc = models.TextField(max_length = 300) authors = models.ManyToManyField(Author, related_name ='author') def __str__(self): return self.book_title def written_by(self): return ",".join([str(p) for p in self.authors.all() ]) views.py from .models import Author, Book # Create your views here. def manytomany(request): authors = Author.objects.all() book = Book.objects.all() # author_first = Author.objects.get(author_name='Mahesh') # book_author = author_first.author.all() book_author = Author.objects.get(id=1).author.all() context = { 'authors':authors, 'book': book, 'book_author':book_author, } return render(request, 'many-to-many.html', context) HTML <div class="col-lg-12"> <table class="table table-striped"> <thead> <tr> <th>Author Name</th> <th>Book</th> </tr> </thead> <tbody> {% for author in authors %} <tr> <td>{{ author.author_name }}</td> {% for j in book_author %} <td>{{ j }}</td> {% endfor %} </tr> {% endfor %} </tbody> </table> </div> -
MultiValueDictKeyError at /signup
I am creating a login in page in django but facing the issue MultiValueDictKeyError at /signup Below is views.py ''' from django.shortcuts import render, redirect from django.http import HttpResponse from django.contrib.auth.models import User from django.contrib import messages def home(request): return render(request, "authentication/index.html") def signup(request): if request.method == "POST": uname = request.POST['uname'] fname =request.POST['fname'] lname = request.POST['lname'] email = request.POST['email'] pass1 = request.POST['pass1'] pass2 = request.POST['pass2'] myuser = User.objects.create_user(uname, email, pass1) myuser.first_name = fname myuser.last_name = lname myuser.save() messages.success(request, "Your account has been successfully created.") return redirect('signin') return render(request, "authentication/signup.html") def signin(request): return render(request, "authentication/signin.html") def signout(request): pass ''' Below is the signup.html ''' <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Database</title> </head> <body> <h3>Sign Up</h3> <form action="/signup" method="post"> {% csrf_token %} <label for="">Username</label> <input type="text" id="uname" placeholder="Create a username", Required> <br> <label for="">First Name</label> <input type="text" id="fname" placeholder="Enter First Name", Required> <br> <label for="">Last Name</label> <input type="text" id="lname" placeholder="Enter Last name", Required> <br> <label for="">Email</label> <input type="email" id="email" placeholder="Enter Email address", Required> <br> <label for="">Password</label> <input type="password" id="pass1" placeholder="Create a Password", Required> <br> <label for="">Confirm your password</label> <input type="password" id="pass2" placeholder="Confirm your password", Required> <br> <button type="submit">Sign Up</button> </form> </body> </html> ''' Below is the Error Message MultiValueDictKeyError at /signup …