Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django related field filter with range
I tried to filter the range of keyword_id in the book table. However, the following error continues to occur. How can I filter the range of keyword_id? here is my code UserBook.objects.prefetch_related('book').filter(book__keyword_id__range(2,7)).values( 'book_id').annotate(count=Count('book_id')).order_by('-count') it is error raise FieldError('Related Field got invalid lookup: {}'.format(lookup_name)) django.core.exceptions.FieldError: Related Field got invalid lookup: range -
Only superuser to make new accounts using Django allauth
I am making a subscription based site using Django allauth. I want it so that only the super user can use the sign up page to register clients, so they then have access to the whole site. I thought I had it by using if statements on the base.HTML page it then when I go to make a new user when still logged in as the super user it does not work! Any suggestions?! Thanks 😃 -
ckeditor-form is not properly shown in server; Django
I have a form that is displayed ok, localy: <form id="form_image" method="POST" enctype="multipart/form-data"> <div class="col"> {% csrf_token %} {{ form.media }} {{ form.as_p }} <input id="bb0" type="submit" class="btn btn-primary" value="Submit"> </div> </form> but on server, it cannot find the recourses: it gives the 404 error that the following is not found: https//mysite.com/static/ckeditor/ckeditor/ckeditor.js where it is in fact is not in that folder anyways. it is a library: any idea that what is missing here? -
Problem with django after installing anaconda
I am working on a Django project and this is what I am getting when I try to run the server. It used to work totally fine but I think the path is missing for virtualenv. I installed anaconda yesterday and the path variable is changed in advanced system settings. How can I revert them back to original settings? Total python newbie here. Kindly help. C:\Users\13157\django_project>python manage.py runserver Traceback (most recent call last): File "manage.py", line 9, 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 "manage.py", line 20, in <module> main() File "manage.py", line 11, 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? C:\Users\13157\django_project> -
django. Form creates blank objects for empty fields. How to prevent this/only create objects for populated fields?
I have several models linked to a single form. The form creates and saves individual model objects. Here are the models. class Quarterback(models.Model): name = models.CharField(max_length=20) score = models.IntegerField(blank=True, null=True) class Runningback(models.Model): name = models.CharField(max_length=20) score = models.IntegerField(blank=True, null=True) class Widereceiver(models.Model): name = models.CharField(max_length=20) score = models.IntegerField(blank=True, null=True) class Tightend(models.Model): name = models.CharField(max_length=20) score = models.IntegerField(blank=True, null=True) class Kicker(models.Model): name = models.CharField(max_length=20) score = models.IntegerField(blank=True, null=True) This is the form. class PlayerForm(forms.Form): quarterback_name = forms.CharField(label='Quarterback', max_length=100, required=False) runningback_name = forms.CharField(label='Runningback', max_length=100, required=False) widereceiver_name = forms.CharField(label='Widereceiver', max_length=100, required=False) tightend_name = forms.CharField(label='Tightend', max_length=100, required=False) kicker_name = forms.CharField(label='Kicker', max_length=100, required=False) def save(self): quarterback_name = self.cleaned_data.get('quarterback_name') Quarterback.objects.create(name=quarterback_name) runningback_name = self.cleaned_data.get('runningback_name') Runningback.objects.create(name=runningback_name) widereceiver_name = self.cleaned_data.get('widereceiver_name') Widereceiver.objects.create(name=widereceiver_name) tightend_name = self.cleaned_data.get('tightend_name') Tightend.objects.create(name=tightend_name) kicker_name = self.cleaned_data.get('kicker_name') Kicker.objects.create(name=kicker_name) The problem I'm having is that I want the option to save only one object and leave the other form fields empty. This sort of works. I can save just one field and therefore create only one object, but my form seems to be creating blank objects for the fields that are left empty. I want to stop these blank objects being created so I tried a few things out. I tried adding an else/if and a "pass" if the field … -
Django Model Design many-to-one?
I'm trying to create two models in Django, 'Paragraph' and 'Sentences'. I still do not seem to understand how the many-to-one function works. If I want there to be a paragraph that holds multiple sentences; do I simply add a ForeignKey(Paragraph) into the Sentences model? That way I can have more than one sentence store inside the Paragraph model. Thank you for any insight as I try to learn Django. -
How to raise multiple ValidationError on Django Rest API?
Suppose I have three serializers in function and I want to check the validation. If any errors occur in the condition it Response error message at a time My function: def employ_create(request): if request.method == 'POST': employ_basic_info = data['basic_info'] employ_academic_info = data['academic_info'] employ_address = data['address'] employ_basic_info_serializer = EmployBasicInfoSerializers(data=employ_basic_info) employ_academic_info_serializer = EmployAcademicInfoSerializers(data=employ_academic_info) employ_address_serializer = EmployAddressInfoSerializers(data=employ_address) if employ_basic_info_serializer.is_valid() and employ_academic_info_serializer.is_valid() and employ_address_serializer.is_valid(): employ_basic_info_serializer.save(employ_id=user_obj) employ_academic_info_serializer.save(employ_id=user_obj) employ_address_serializer.save(employ_id=user_obj) return Response(status=rest_framework.status.HTTP_200_OK) status_errors = { 'employ_basic_info_error':employ_basic_info_serializer.errors, 'employ_academic_info_error':employ_academic_info_serializer.errors, 'employ_address_error':employ_address_serializer.errors, } return Response({'stutase':status_errors}, status=rest_framework.status.HTTP_400_BAD_REQUEST) I want to return employ_basic_info_serializer, employ_academic_info_serializer, employ_address_serializer errors if any errors occur. How can I do it? pls, help me... -
Django - No Category matches the given query
I'm implementing a view that outputs a table as a .csv file, but when I try to run it, it throws a 404 error with this description, and it says that it was raised by a view called "catalog.views.product_list", which doesn't exist anymore, as I deleted it. views.py: @login_required def export_csv(request): categories = Category.objects.filter(company=request.user.profile.company) queryset = Product.objects.filter(category__in=categories) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = f'filename=productos.csv' writer = csv.writer(response) writer.writerow(['Id de Producto', 'Categoría', 'Nombre del producto', 'SKU', 'Código de barras', 'Marca', 'Proveedor', 'Color', 'Medidas', 'Descripción', 'Observaciones', 'Precio 1', 'Precio 2', 'Precio 3', 'Impuesto (%)', 'Costo de fabricación']) for item in queryset: writer.writerow([item.id, item.category.name, item.name, item.sku, item.barcode, item.brand, item.provider, item.color, item.measures, item.description, item.observations, item.price_1, item.price_2, item.price_3, item.tax, item.fabrication_cost]) return response urls.py from django.urls import path from . import views app_name = 'catalog' urlpatterns = [ path('catalog/list/', views.ProductList.as_view(), name='product_list_table'), path('catalog/add/', views.create_product, name='add_product'), path('catalog/category/add/', views.CategoryCreate.as_view(), name='add_category'), path('catalog/<slug>/list/', views.CategoryProductList.as_view(), name='category_product_list_table'), path('catalog/<int:id>/<slug:slug>/', views.product_detail, name='product_detail'), path('catalog/<int:id>/<slug:slug>/edit/', views.edit, name='product_edit'), path('catalog/export_csv/', views.export_csv, name='export_all_csv'), ] The button that triggers the view: <li class="nav-item"> <a href="{% url 'catalog:export_all_csv' %}" class="btn btn-success btn-sm" download="Productos" tabindex="0" data-toggle="popover" data-trigger="focus" title="¡Archivo descargado!" data-content="El archivo ha sido descargado exitosamente."> <i class="uil-file"></i> Exportar a Excel </a> </li> I don't get how a view that was deleted already is causing … -
How to fix AttributeError: 'Like' object has no attribute 'filter'
I am trying to add a condition to my notification to check if a user's total number of likes for all the posts related to him and send a notification if reached a certain number. I have filtered the total likes by the post author but I keep receiving AttributeError: 'Like' object has no attribute 'filter' To summarize here is the post model class Post(models.Model): author = models.ForeignKey( User, on_delete=models.CASCADE, related_name='author') num_likes = models.IntegerField(default=0, verbose_name='No. of Likes') likes = models.ManyToManyField(User, related_name='liked', blank=True) Here is the likes model class Like(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) value = models.CharField(choices=LIKE_CHOICES, default='Like', max_length=8) def like_progress(sender, instance, *args, **kwargs): like = instance.filter(post__author=Post.author).count() post = like.post sender = like.user if like == 12: notify = Notification(post=post, sender=sender, user=post.author, notification_type=3) notify.save() My Question: How to fix this error? -
Django SQLite on Heroku doesn't recognize any of the changed models and throws a "relation doesn't exist" error
I changed the name of several models on Django. Successfully ran makemigrations and migrate. I can interact with the SQLite directly as admin or through requests on localhost. before changing the tables I had deployed to Heroku and it was working. when I changed the model names and pushed to Heroku (after successfully running on localhost) I get issues. When I login as admin to the site (on Heroku) I can interact with tables like User and Token, but not with the newly updated models. as soon as I click on them I get bellow error. when I click on add to these models, the columns appear but as soon as I hit save I get below error as well. ProgrammingError at /admin/app_name/model_name/ relation "app_name_model_name" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "app_name_model_name" I kept the Debug=True to see what's going on otherwise I get "500 Internal Server Error". I have added heroku's site as "ALLOWED_HOSTS". When I was trying to make the migrations work, I had delete the files on the migration folder. not sure if there is a similar process on Heroku or if I'm missing something else? By the way I have ran the … -
Django URLs and include() - how do you differentiate between 2 urls with the same "name" in 2 separate apps?
I have 2 apps in my project, "landing" and "news". Right now, I have the URLs configured like this: project/urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('', include('landing.urls')), path('news/', include('news.urls')), ] project/landing/urls.py: urlpatterns = [ path('', landing_view, name='landing'), ] project/news/urls.py: urlpatterns = [ path('', news_view, name='news'), ] navbar link hrefs: href="{% url 'landing' %}" href="{% url 'news' %}" I believe this setup is pretty standard and it all works fine so far. What I don't like is that this setup depends on each app having unique names for each url path. I'd like to be able to specify the app when referencing a URL name. That way I wouldn't have to worry about accidentally re-using the same name for a url in different apps. The documentation mentions using app_name/namespace parameters, but they don't give any examples for how to reference a url in the url tag. I've tried something like this: project/urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('', include('landing.urls', namespace='landing', app_name='landing')), path('news/', include('news.urls', namespace='landing', app_name='landing')), ] project/landing/urls.py: urlpatterns = [ path('', landing_view, name='index'), ] project/news/urls.py: urlpatterns = [ path('', news_view, name='index'), ] navbar link hrefs: href="{% url 'landing:index' %}" href="{% url 'news:index' %}" But I get this error: path('', include('landing.urls', namespace='landing', … -
My template isn't loading, but base.html is?
I'm trying to render a class based view through my template, chart.html, however I'm only able to get {% extends 'base.html' %} able to load when I test my app on localhost. Below is my view and template files for my chart.html and base.html. Note that im not getting any syntax errors in my console. Would greatly appreciate some expertise here. I don't think its a URL issue because when I land on the URL, i get the base.html template loaded, just not its main template aka chart.html. views.py from django.contrib.auth import get_user_model from rest_framework.views import APIView from rest_framework.response import Response from django.shortcuts import render from django.views.generic import View User = get_user_model() # Create your views here. class IndexView(View): def get(self, request, *args, **kwargs): return render(request, 'chart.html', {}) class ChartData(APIView): authentication_classes = [] permission_classes = [] def get(self, request, format=None): data = { "sales": 100, "customers": 10, "users": User.objects.all().count(), } return Response(data) chart.html {% extends 'base.html' %} <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.css'></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <script> {% block jquery %} var endpoint = '/api/chartdata/' $.ajax({ method: "GET", url: endpoint, success: function(data){ console.log(data) console.log(data.customers) }, error: function(error_data){ console.log("error") console.log(error_data) } }) {% endblock %} </script> {% block content %} <h1>Hello World</h1> … -
Can I calculate the geometric mean with django annotation?
Is there a way to use it like Foo.objects.annotate(geometric_mean=GeometricMean('bars__value')) or Foo.objects.annotate(geometric_mean=Power(Prod('bars_value'), Count('bars'))? -
I am having trouble changing the url.py within Django
Hello I am needing assistance. I am currently doing within url.py for Django: urlpatterns = [ path('cookies/', admin.site.urls), ] This is being done from urls.py in atom and when I look at the terminal it is not able to GET the new url. When I have 127.0.0.1/cookies/ I am still directed to a not found page. Anyone please help I am currently using Ubuntu Linux. -
Django filter match url irrespective or protocol
I have below Django filter. It has one field as url. class MediaFilter(filters.FilterSet): """Filters for the MediaViewset endpoint /media """ type = django_filters.CharFilter() category = django_filters.ModelMultipleChoiceFilter( queryset=Category.objects.all(), field_name="category__name", to_field_name="name", conjoined=False, ) person_id = NumberInFilter( field_name="persons__id", lookup_expr="in", distinct=True, ) url = django_filters.CharFilter(field_name="url", lookup_expr="exact") nsfw = django_filters.BooleanFilter() class Meta: model = Media fields = ["type", "category", "person_id", "url", "nsfw"] My doubt is how do I filter for url without considering "http://www" part. For example all below combination should be considered as same. And url should always be matched by removing "^.*//www." part from it. https://www.youtube.com/watch?v=dFspPk5AUTU youtube.com/watch?v=dFspPk5AUTU http://youtube.com/watch?v=dFspPk5AUTU Please advice how do I control it? -
Rendering a custom tag with a foreign key into templates issues
Hi this is the model I am working with from django.db import models from users.models import CustomUser class Project(models.Model): id = models.AutoField(primary_key=True) user = models.ForeignKey(CustomUser, on_delete=models.PROTECT, editable=False) name = models.CharField(max_length=20, editable=False) total = models.DecimalField(max_digits=6, decimal_places=2, editable=False) created = models.DateTimeField(auto_now_add=True, editable=False, null=False, blank=False) def __str__(self): return self.name The class is populated by an HTML form using this view: def homepage(request): if request.method == "POST": project = Project() name = request.POST.get('name') total = request.POST.get('total') created = datetime.datetime.now() user = request.user project.user = user project.name = name project.total = total project.created = created project.save() #return HttpResponse(reverse("homepage.views.homepage")) return render(request, 'homepage.html') else: return render(request, 'homepage.html') and so I have added a custom tag into my app which is a function @register.filter def monthlyTotal(user): this_month = now().month return Project.objects.filter( created__month=this_month, user=user ).aggregate( sum_total=Sum('total') )['sum_total'] I call the tag like this in template <p>Total monthly sales = {{ user.username|monthlyTotal }}</p> however I get an error saying Field ID expected a number but got 'grandmaster' which is the name of my test user who has multiple Project objects.. if I switch to user.id I get no error but it displays None which makes sense because when I look at my project section in admin the field user is … -
Django cannot add background image from css
I've followed the django official document to set the static path. Document In my html, i tried : {% load static %} <link href="{% static 'css/landing-page.min.css' %}" rel="stylesheet"> Also in my setting.py, I confirmed that STATIC_URL = '/static/' is there as default. I create a new folder called static under my app folder where render this HTML page and also create the same folder under my project, I keep the content all the same in both of them because I was not sure which one really is the "static" path it recognized. It seems like the HTML gets its CSS, but not matter how I changed the path in the CSS, the image just doesn't appear. I tried the solution here Add background image in css, and it doesn't at all. I tried: header.masthead { position: relative; background-color: #343a40; background: url("../static/img/main.jpg") no-repeat center center; background-size: cover; padding-top: 8rem; padding-bottom: 8rem; } It doesn't work Please help me. Thanks! -
Django - Dynamic filters in a webpage
I am still a learner for python django. I’d like to filter dynamically data on the table below table The informations in my html template are : <table> <thead> <tr> <th>N°Commande</th> <th>Magasin</th> <th>Objet</th> <th>Date commande</th> <th>Montant</th> <th>Etat</th> </tr> </thead> <tbody> {% for item in query_results %} <tr> <td>{{ item.numero_commande }}</td> <td>{{ item.enseigne}}</td> <td>{{ item.Objet}}</td> <td>{{ item.Date_commande}}</td> <td>{{ item.Montant}}</td> <td>{{ item.Etat}}</td> </tr> </tbody> from the class : class Commande(models.Model) Here is an exemple of what I’d like to have (filters on table fields) : table with dynamic filters thank you in advance for your help Vinloup -
Reverse for 'blog/article' not found. 'blog/article' is not a valid view function or pattern name
I am currently doing a navbar in my django website. However, I'm experiencing some problems with the urls: I have created another urls.py in a new app called blogs. Here's the code for that: In the main urls.py: from django.contrib import admin from django.urls import path, include from translator.views import HomeView, TranslatorView urlpatterns = [ path('blog/', include('blog.urls')), path('', HomeView.as_view(), name='home'), path('translator/<str:phrase>/', TranslatorView.as_view(), name='translator'), path('translated/', TranslatorView.as_view(template_name='main/translated.html'), name='translated'), path('admin/', admin.site.urls), ] In the blog urls.py: from django.urls import path from .views import ArticleDetailView app_name = 'blog' urlpatterns = [ path('', ArticleDetailView.as_view(), name='article' ) ] What I want to do is to include the path ArticleDetailView (name='article) in the navbar. So I coded this: <nav class="navbar fixed-top navbar-expand-lg navbar-light" style='background-color: snow;'> <div class = 'container'> <a class="navbar-brand" href="#"> <img src="{% static 'C:\Users\marcv\OneDrive\Escriptori\Translate\Scripts\src\static\images\dna_PNG48.png'%}" width="70" height="30" class="d-inline-block align-top" alt=""> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarTogglerDemo01"> <ul class="navbar-nav mx-auto"> <li class="nav-item active"> <a class="nav-link" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link" href='{% url "translator" "phrase" %}'>Translator</a> </li> <li class="nav-item"> <a class="nav-link" href="{% url 'blog/article' %}" >Blog</a> #Here's the problem </li> </ul> </div> </div> </nav> However, when I click on the navbar … -
Adding a link to another page in Django(3.1) (NoReverseMatch)
I'm trying to add a link to another page on my index page, but when I use {% url 'blog:BlogAbout' %} I get: Exception Type: NoReverseMatch Exception Value:'blog' is not a registered namespace index.html: <a href="{% url 'blog:BlogAbout' %}">About Me</a> blog.urls.py: path('about/', views.about, name="BlogAbout"), blog.views.py: def about(request): return render(request, 'blog/about.html') urls.py: path('', include('blog.urls')), The question is almost familiar to this: How do I add link to another page [Django 3.0]? Reverse not found I'm doing it like there but I still get an error. What is the right way to add the link? -
from django.db import models from django.utils import timezone
from django.db import models Create your models here. from django.db import modelsfrom django.utils import timezone from django.contrib.auth.models import User class Post(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published'), ) title = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique_for_date='publish') author = models.ForeignKey(User, related_name='blog_posts') body = models.TextField() publish = models.DateTimeField(default=timezone.now) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') class Meta: ordering = ('-publish',) def __str__(self): return self.title -
Connecting PowerBI Online with my local Analysis Services: there was a data source access error. please contact the gateway administrator
I am trying to publish my reports to PowerBI online so I can embed it into my web application (developed using Django framework and Python). I installed the gateway On-premise, my cube already created in my Analysis Services SQL server. I configured the gateway like in the tutos but still not working, I can't access data in my dashboard. Connectivity is good Still I got the errors I tried every solution on the internet I could found, please any solution? and if you have any other idea of how to embed my reports into my application. thanks a lot. -
Stripe payment - Why when I call if payment_form.is_valid(): is it always invalid?
I am trying to take a Stripe payment but every time the function is_valid() returns false and the message "We were unable to take a payment with that card!" is displayed. The payment is for a set amount of 5 Euros. I am using the credit card number 4242 4242 4242 4242 to test the payment. Can anyone help me find what is wrong with my form? checkout.html: {% extends "base.html" %} {% load static from staticfiles %} {% load bootstrap_tags %} {% block head_js %} <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <script type="text/javascript"> //<![CDATA[ Stripe.publishableKey = '{{publishableKey}}'; // ]]> </script> <script type="text/javascript" src="{% static 'js/stripe.js' %}"></script> {% endblock %} {% block content %} <form action="{% url 'checkout' %}" method="post" id="payment-form" class="col-md-6 col-md-offset-3"> <legend>Payment Details</legend> <div id="credit-card-errors" style="display: none;"> <div id="alert-message block-message error" id="stripe-error-message"></div> </div> <div class="form-group col-md-6"> {{ payment_form | as_bootstrap }} </div> {% csrf_token %} <div class="form-group col-md-12"> <input class=" btn btn-primary" id="submit_payment_btn" name="commit" type="submit" value="Submit Payment"> </div> </form> {% endblock %} forms.py: from django import forms class MakePaymentForm(forms.Form): month_choices = [(i,i) for i in range(1,13)] year_choices = [(i,i) for i in range(2018,2040)] credit_card_number = forms.CharField(label='Credit Card Number', required=False) cvv = forms.CharField(label ='Security Code', required=False) expiry_month = forms.ChoiceField(label="Month",choices=month_choices, required=False) expiry_year = … -
Djoser + Django-Rest verify user before activation email is sent?
I would like to use Djoser's built in "send activation email" with the activation link on user registration. But I want to manually verify a user (click a boolean field in django-admin for example) before the email is sent to the user. How/where would you add this extra step/stop in the registration flow? -
django botcatcher does not activate
I have a web page with 3 forms each with their own submit button. On the second form I'm trying to implement a botcatcher by creating a hidden field and checking it's length. I can't seem to get this to work. Here are the relevant files: form_page.html <!DOCTYPE html> {% load static %} <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="{% static 'basicapp/style.css' %}"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" > <title>Forms</title> </head> <body> <h2>welcome to our first form</h2> <div class="container"> <div class="jumbotron"> <form name='form001' method="post"> {% csrf_token %} {{ form.as_p }} <input type='submit' class="btn btn-primary" name='whichForm' value="Submit"> </form> </div> <div class='jumbotron'> <form method="post"> {% csrf_token %} {{ form1.as_p }} <input type='submit' class="btn btn-primary" name='whichForm' value="Submit1"> </form> </div> <div class='jumbotron'> <form method="post"> {% csrf_token %} {{ form2.as_p }} <input type='submit' class="btn btn-primary" name='whichForm' value="Submit2"> </form> </div> </div> </body> </html> views.py from django.shortcuts import render from . import forms # Create your views here. def index(request): return render(request,'basicapp/index.html') def myform_view(request): form = forms.MyForm() form1 = forms.MyForm1() form2 = forms.MyForm2() if request.method == 'POST': if request.POST['whichForm'] == 'Submit': temp = forms.MyForm(request.POST) elif request.POST['whichForm'] == 'Submit1': temp = forms.MyForm1(request.POST) elif request.POST['whichForm'] == 'Submit2': temp = forms.MyForm2(request.POST) if form.is_valid(): print("VALIDATION SUCCESS!") print("NAME: " + temp.cleaned_data['name']) print("EMAIL: …