Tsallaka zuwa abun ciki
Justice Tech School

Forms

A Form class declares fields and validation. In a template it renders HTML inputs. Always include {% csrf_token %} in POST forms.

Example
from django import forms

class ContactForm(forms.Form):
    name = forms.CharField(max_length=50)
    email = forms.EmailField()
    message = forms.CharField(widget=forms.Textarea)

Exercise

Email input field.

email = forms.Field()

Quiz Test

What does csrf_token protect against?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.