Top "Django-forms" questions

Specific questions related to forms with the Django web framework

How to insert a checkbox in a django form

I've a settings page where users can select if they want to receive a newsletter or not. I want a …

python django django-forms
Django: How do I add arbitrary html attributes to input fields on a form?

I have an input field that is rendered with a template like so: <div class="field"> {{ form.city }} &…

django django-templates django-forms django-widget html
Django ModelForm to have a hidden input

So I have my TagStatus model. I'm trying to make a ModelForm for it. However, my form requires that the …

python django django-models django-forms
Create empty queryset by default in django form fields

I have this fields in form: city = forms.ModelChoiceField(label="city", queryset=MyCity.objects.all()) district = forms.ModelChoiceField(label="district", …

django django-forms
Overriding the save method in Django ModelForm

I'm having trouble overriding a ModelForm save method. This is the error I'm receiving: Exception Type: TypeError Exception Value: save() …

python django django-forms django-admin
How to update an object from edit form in Django?

Possibly a newbie question, so please bear with me. I have a Django form that edits a certain instance of …

django django-forms
dynamically add field to a form

I have 3 fields in my form. I have a submit button and a button to "Add additional Field". I understand …

python django django-forms
Django ModelForm for Many-to-Many fields

Consider the following models and form: class Pizza(models.Model): name = models.CharField(max_length=50) class Topping(models.Model): name = …

python django django-forms
Django, ModelChoiceField() and initial value

I'm using something like this: field1 = forms.ModelChoiceField(queryset=...) How can I make my form show the a value as …

django django-forms
Django form - set label

I have a form that inherits from 2 other forms. In my form, I want to change the label of a …

python django inheritance django-forms