Recall & Review
beginner
What is a form field in Django?
A form field in Django represents a single piece of data that a user can enter or select in a form. It defines the type of data expected, like text, number, or date.
Click to reveal answer
beginner
What is a widget in Django forms?
A widget controls how a form field is displayed in HTML. It decides the HTML input element used, like a text box, checkbox, or dropdown.
Click to reveal answer
intermediate
How do you change the widget of a form field in Django?
You can change a field's widget by setting the 'widget' attribute when defining the field, for example:
forms.CharField(widget=forms.Textarea()) to use a textarea instead of a text input.Click to reveal answer
beginner
Name three common Django form fields and their default widgets.
1. CharField - TextInput widget<br>2. BooleanField - CheckboxInput widget<br>3. ChoiceField - Select widget
Click to reveal answer
intermediate
Why is it important to use widgets in Django forms?
Widgets help control the user experience by choosing the right HTML input type. They also help with accessibility and styling, making forms easier and clearer to use.
Click to reveal answer
Which Django form field would you use to accept a user's email address?
✗ Incorrect
forms.EmailField is designed to accept and validate email addresses.
What widget does Django use by default for a BooleanField?
✗ Incorrect
BooleanField uses CheckboxInput by default to show a checkbox.
How can you make a CharField display as a multi-line text box?
✗ Incorrect
Using widget=forms.Textarea changes the input to a multi-line text box.
Which widget would you use to let users pick from a list of options?
✗ Incorrect
Select widget shows a dropdown list for choosing options.
What is the main role of a widget in Django forms?
✗ Incorrect
Widgets control the HTML representation of form fields.
Explain what form fields and widgets are in Django and how they work together.
Think about the data you want and how it looks on the page.
You got /4 concepts.
Describe how you would customize a Django form field to use a different widget and why you might do that.
Consider changing a text box to a bigger input area.
You got /3 concepts.