0
0
Djangoframework~10 mins

Field options (max_length, null, blank, default) 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 set the maximum length of a CharField to 100.

Django
name = models.CharField(max_length=[1])
Drag options to blanks, or click blank then click option'
A100
B50
C255
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer for max_length.
Omitting the max_length option for CharField.
2fill in blank
medium

Complete the code to allow the database field to store NULL values.

Django
age = models.IntegerField(null=[1])
Drag options to blanks, or click blank then click option'
ANone
B'True'
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string 'True' instead of the boolean True.
Confusing null with blank.
3fill in blank
hard

Fix the error in the code to allow the form to accept empty input for the field.

Django
email = models.EmailField(blank=[1])
Drag options to blanks, or click blank then click option'
A'False'
BNone
CFalse
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using blank=None which is invalid.
Confusing blank with null.
4fill in blank
hard

Fill both blanks to set a default value and allow blank input for a CharField.

Django
status = models.CharField(max_length=20, default=[1], blank=[2])
Drag options to blanks, or click blank then click option'
A'pending'
BTrue
CFalse
D'active'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a boolean for default instead of a string.
Setting blank to False when empty input is needed.
5fill in blank
hard

Fill all three blanks to create a TextField that allows NULL in database, blank input in forms, and has a default empty string.

Django
description = models.TextField(null=[1], blank=[2], default=[3])
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C''
D'None'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting default to 'None' string instead of empty string.
Confusing null and blank options.