We will implement the form feature, which, in essence, is another view in our blog application. To do this, perform the following steps:
- First, create a new Python script inside the blog folder in the forms.py directory, as follows:
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 ...