September 2019
Beginner to intermediate
494 pages
13h
English
We will implement the form feature, which, in essence, is another view in our blog application. To do this, perform the following steps:
from django import formsclass EmailPostForm(forms.Form): name = forms.CharField(max_length=25) email = forms.EmailField() to = forms.EmailField() comments = forms.CharField(required=False, widget=forms.Textarea)
You can see that this file resembles a model declaration in Django; while the basic implementation is similar, Django forms are organized in the forms.py directory, separate from models. Here, we can see that, once again, Django offers an easy and straightforward ...