from django.forms import ModelForm from myapp.models import Article
class ArticleForm(ModelForm): ... class Meta: ... model = Article ... fields = ["pub_date", "headline", "content", "reporter"] ...
form = ArticleForm()
article = Article.objects.get(pk=1) form = ArticleForm(instance=article)
Create the form class.
Creating a form to add an article.
Creating a form to change an existing article.