0
0
Djangoframework~10 mins

Field types (CharField, IntegerField, DateField) 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 define a character field with a maximum length of 100.

Django
name = models.[1](max_length=100)
Drag options to blanks, or click blank then click option'
ACharField
BIntegerField
CTextField
DDateField
Attempts:
3 left
💡 Hint
Common Mistakes
Using IntegerField for text data.
Forgetting to set max_length for CharField.
2fill in blank
medium

Complete the code to define a field that stores whole numbers.

Django
age = models.[1]()
Drag options to blanks, or click blank then click option'
AIntegerField
BCharField
CDateField
DFloatField
Attempts:
3 left
💡 Hint
Common Mistakes
Using CharField for numbers.
Using FloatField when whole numbers are needed.
3fill in blank
hard

Fix the error in the code to correctly define a date field.

Django
birth_date = models.[1](auto_now_add=True)
Drag options to blanks, or click blank then click option'
ADateTimeField
BCharField
CIntegerField
DDateField
Attempts:
3 left
💡 Hint
Common Mistakes
Using IntegerField or CharField for dates.
Confusing DateField with DateTimeField.
4fill in blank
hard

Fill both blanks to define a model field for a user's joining date that sets automatically when created and does not change.

Django
joined = models.[1](auto_[2]=True)
Drag options to blanks, or click blank then click option'
ADateField
BIntegerField
Cnow_add
Dauto_now
Attempts:
3 left
💡 Hint
Common Mistakes
Using auto_now instead of auto_now_add for creation date.
Using IntegerField for dates.
5fill in blank
hard

Fill all three blanks to define a model field for a user's last login date that updates automatically every time the record is saved.

Django
last_login = models.[1](auto_[2]=True, null=[3])
Drag options to blanks, or click blank then click option'
ADateField
BFalse
CTrue
Dauto_now
Attempts:
3 left
💡 Hint
Common Mistakes
Using auto_now_add instead of auto_now for update date.
Not allowing null values when needed.