The Course App

Introduction to Django forms

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

New files

app/forms.py
from django import forms


class CreateArticleForm(forms.Form):
    ARTICLE_STATUS = (
        ("draft", "draft"),
        ("inprogress", "in progress"),
        ("published", "published"),
    )

    title = forms.CharField(max_length=100)
    status = forms.ChoiceField(choices=ARTICLE_STATUS)
    content = forms.CharField(widget=forms.Textarea)
    word_count = forms.IntegerField()
    twitter_post = forms.CharField(widget=forms.Textarea, required=False)