When using ModelForm Within forms.py it would save a lot of time, since there is no need to rewrite the whole fields again in forms.
class ContactsForm(ModelForm):
class Meta:
model = Contact
Taking a forms.Form instead would require to define all fields again manually. Some would prefer this approach due more control.
While a lot of it is straight forward:
models.CharField("First Name",max_length=30, blank=True)
becomes
forms.CharField(label = _(u'First Name'), max_length=30, blank=True)
and models.TextField(blank=True) becomes forms.TextArea(blank=True) etc…
One field is a bit of a mystery to me how it would be translated in forms, such as:
models.ForeignKey(ContactType)
How is a dropdownmenu to be defined within forms?
Do you mean something like this?:
More about
ModelChoiceFieldon Django’s documentation