0
0
Djangoframework~10 mins

Form validation (is_valid, cleaned_data) 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 check if the form data is valid.

Django
if form.[1]():
    print("Valid data")
Drag options to blanks, or click blank then click option'
Acleaned_data
Bsave
Cfull_clean
Dis_valid
Attempts:
3 left
💡 Hint
Common Mistakes
Using cleaned_data() instead of is_valid()
Calling save() before validation
2fill in blank
medium

Complete the code to access the cleaned form data after validation.

Django
if form.is_valid():
    name = form.[1]['name']
Drag options to blanks, or click blank then click option'
Afields
Bdata
Ccleaned_data
Derrors
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access data before calling is_valid()
Using errors instead of cleaned_data
3fill in blank
hard

Fix the error in accessing cleaned data from the form.

Django
if form.is_valid():
    age = form.cleaned_data[1]('age')
Drag options to blanks, or click blank then click option'
A[]
B.get
C{}
D()
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets
Trying to call cleaned_data as a function
4fill in blank
hard

Fill both blanks to validate the form and print the cleaned email.

Django
if form.[1]():
    print(form.cleaned_data[2]['email'])
Drag options to blanks, or click blank then click option'
Ais_valid
B()
C[]
Dclean
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation instead of square brackets for cleaned_data
Forgetting parentheses on is_valid
5fill in blank
hard

Fill both blanks to validate the form, get the username, and print it.

Django
if form[1]:
    username = form.cleaned_data[2]['username']
    print(username)
Drag options to blanks, or click blank then click option'
A.is_valid()
B[]
D()
Attempts:
3 left
💡 Hint
Common Mistakes
Missing parentheses on is_valid
Using parentheses instead of square brackets for cleaned_data
Adding extra parentheses in print