0
0
Djangoframework~10 mins

Formsets for multiple forms in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the formset factory function from Django forms.

Django
from django.forms import [1]
Drag options to blanks, or click blank then click option'
AFormset
BFormSet
Cform_factory
Dformset_factory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'FormSet' instead of 'formset_factory'.
Misspelling the function name.
2fill in blank
medium

Complete the code to create a formset class for a form named 'BookForm'.

Django
BookFormSet = [1](BookForm, extra=3)
Drag options to blanks, or click blank then click option'
AFormSet
Bformset_factory
CFormFactory
Dform_factory
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class name instead of the factory function.
Using incorrect capitalization.
3fill in blank
hard

Fix the error in the code to instantiate a formset with POST data.

Django
formset = BookFormSet([1]=request.POST)
Drag options to blanks, or click blank then click option'
Adata
Bpost
Crequest
Dform_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' or 'request' instead of 'data'.
Passing POST data without a keyword argument.
4fill in blank
hard

Fill both blanks to create a formset for 'AuthorForm' with 2 extra forms and validate it.

Django
AuthorFormSet = [1](AuthorForm, extra=[2])
formset = AuthorFormSet()
if formset.is_valid():
    # process data
Drag options to blanks, or click blank then click option'
Aformset_factory
B3
C2
DFormSet
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'FormSet' instead of 'formset_factory'.
Setting extra to 3 instead of 2.
5fill in blank
hard

Fill all three blanks to create a formset for 'PublisherForm', instantiate it with POST data, and check if it is valid.

Django
PublisherFormSet = [1](PublisherForm, extra=1)
formset = PublisherFormSet([2]=request.POST)
if formset.[3]():
    # save data
Drag options to blanks, or click blank then click option'
Aformset_factory
Bdata
Cis_valid
DFormSet
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'FormSet' instead of 'formset_factory'.
Passing POST data with wrong keyword.
Calling a wrong method instead of 'is_valid()'.