Top "Django-forms" questions

Specific questions related to forms with the Django web framework

Django set default form values

I have a Model as follows: class TankJournal(models.Model): user = models.ForeignKey(User) tank = models.ForeignKey(TankProfile) ts = models.…

python django django-models django-forms
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 …

python html django django-forms
Django Forms: if not valid, show form with error message

In Django forms, it can check whether the form is valid: if form.is_valid(): return HttpResponseRedirect('/thanks/') …

django django-forms
CSS styling in Django forms

I would like to style the following: forms.py: from django import forms class ContactForm(forms.Form): subject = forms.CharField(…

css django django-forms
Define css class in django Forms

Assume I have a form class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker = forms.…

python django django-forms
How do I filter ForeignKey choices in a Django ModelForm?

Say I have the following in my models.py: class Company(models.Model): name = ... class Rate(models.Model): company = models.…

python django django-forms
Setting the selected value on a Django forms.ChoiceField

Here is the field declaration in a form: max_number = forms.ChoiceField(widget = forms.Select(), choices = ([('1','1'), (…

django django-models django-forms
What's the best way to store Phone number in Django models

I am storing a phone number in model like this: phone_number = models.CharField(max_length=12) User would enter a …

django django-forms django-validation
Creating a dynamic choice field

I'm having some trouble trying to understand how to create a dynamic choice field in django. I have a model …

python django django-forms django-templates
How can I build multiple submit buttons django form?

I have form with one input for email and two submit buttons to subscribe and unsubscribe from newsletter: <form …

python django button django-forms submit