Django simplify and automates the process to create a form in simple steps.
A tipical workflow when creating a form in Django consists of these three steps:
Creating the form
# forms.py from django import forms class ContactForm(forms.Form): name = forms.CharField(label='Full name', max_length=70)
from django.forms import ModelForm from myapp.models import News class ArticleForm(ModelForm): class Meta: model = News fields = ['title', 'content']
Creating an empty form to add an article.
form = ArticleForm()
Creating a form to change an existing article.
article = Article.objects.get(pk=1) form = ArticleForm(instance=article)