Category "django-forms"

ManyToMany Relationship between two models in Django

I am trying to build a website that users can add the courses they are taking. I want to know how should I add the ManyToMany relationship. Such that we can ge

Why should I set max_length when using Choices in a Django model?

In the official Django 2 tutorial I found this: from django.db import models class Student(models.Model): FRESHMAN = 'FR' SOPHOMORE = 'SO' JUNIOR

Is it possible to submit multiple forms at once using Django views?

What I want to accomplish is to be able to submit multiple forms contained on one page. What I have currenlty done is supplied a view that returns 8 forms. Is i

nothing happens when submitting django form

I have a problem with django forms, when submitting a form nothing seems to happen, even the server didn't get any response except GET request to view the form

Enable post of HTML form to Django database backend

I'm trying to write the code to enable form data to be sent to the backend database. The form is just a few fields, name, website, and portfolio address created

Django form with two submit buttons . . . one requires fields and one doesn't

I think this should be a fairly straightforward question . . . I have ONE Django form with TWO different submit buttons. The first submit button is just for SAV

how to pass extra custom attribute in Django template from "select option" form to a view

I have an html form include a select input in Django template, and the option has an extra attribute value called "testvalue". I want to pass the "testvalue" at

Only accept 2 digits integer array in django model form

How to make a form field that accept 2 digit numeric array in frontend. if someone enter more then 2 digit or string then The input value is automatically valid

Python(Django) :I want the payment form(code) triggered whenever a user clicks the submit button and only saved into DB if payment is succesful

I am currently using DJANGO How can I make the payment form(code) triggered when a user clickn submit and also make it saved into DB after successful payment. P

How to remove the choice field based on relationships between instances in the database in Django

I'm new to django and I would like to ask a question about a case that I can't solve if for example I have many categories, in these categories I can have one o

In Django, how can we stop losing the details filled in the form, if it fails validation?

I am using the UserCreationForm for user registration in my Django web app. When the user fills in the detail (username, password, confirm_password) and submits

Django Nested Inline Formsets to Populate Multilevel Nested Form

I'm trying to solve a problem. I have a model hierarchy like this: class Task(models.Model): name = models.CharField(max_length=255) number_of_steps = m

request.FILES always empty on file upload

I am totally stumped on this, and must be doing something incredibly stupid. I am trying to simply upload a file on a Django project. The problem seems to be th

change datetime format using tempus_dominus DateTimePicker

I installed and imported DateTimePicker and used it as a widget to a Django DateTime Field When clicking on the field it shows me the date and time in format 07

How to change the validation error color and position in Django?

I am new to Django. I am trying to make a simple form to match the password. However, when I enter different passwords and press the Save button I get a black v

Django-admin: show multi select field for JSONField

I have a model with a field channel (JSONField). I'm strong an array of string in db with channel. By default, a JSONField is shown as a textarea in django-admi

How to add custom views or overide views for Django Admin index?

urls.py -> ''''from django.contrib import admin from django.urls import path from Administrator import views admin.site.index_template = 'admi

Change a Django form field to a hidden field

I have a Django form with a RegexField, which is very similar to a normal text input field. In my view, under certain conditions I want to hide it from the use

Django - Adding initial value to a formset

I have a many-to-many relationship between two classes (Lesson and Student), with an intermediary class (Evaluation). I am trying to set up a form which will a

How to test a Django form with a ModelChoiceField using test client and post method

How do I use Django test client.post to test a form that has a ModelChoiceField? How should the data dictionary passed to the post method be written? The way I