Complete the code to import Django's form class.
from django import [1]
The forms module in Django provides tools to create and handle forms easily.
Complete the code to define a simple Django form with a single text field.
class NameForm([1].Form): your_name = [1].CharField(label='Your name', max_length=100)
Use forms.Form to create a form class and forms.CharField to add a text input field.
Fix the error in the form validation code by completing the blank.
if request.method == 'POST': form = NameForm(request.[1]) if form.is_valid(): # process data
When handling form submission, use request.POST to get the submitted form data.
Fill both blanks to create a form that includes an email field and a submit button in the template.
<form method='post'> {% csrf_token %} {{ form.[1] }} <button type='[2]'>Submit</button> </form>
as_table or text instead of as_pUse form.as_p to render form fields wrapped in paragraphs, and type='submit' for the button to submit the form.
Fill all three blanks to create a form class with a required email field, a clean method to validate it, and raise an error if invalid.
class EmailForm(forms.Form): email = forms.[1](required=True) def clean_email(self): email = self.cleaned_data.get('[2]') if not email.endswith('[3]'): raise forms.ValidationError('Email must end with example.com') return email
Use EmailField for email input, access it by its name email in cleaned_data, and check it ends with example.com.