Challenge - 5 Problems
Field Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the default max length of a CharField in Django?
Consider the following Django model field:
What will happen when you run migrations?
name = models.CharField()
What will happen when you run migrations?
Attempts:
2 left
💡 Hint
Think about what Django requires for CharField length.
✗ Incorrect
CharField requires max_length to be specified. Omitting it causes a TypeError during migration generation.
❓ state_output
intermediate1:30remaining
What value is stored in the database for this IntegerField?
Given this model field:
What will be the value of age if you create a new instance without specifying age?
age = models.IntegerField(default=18)
What will be the value of age if you create a new instance without specifying age?
Attempts:
2 left
💡 Hint
Check the default parameter behavior.
✗ Incorrect
The default value 18 is used when no value is provided during instance creation.
📝 Syntax
advanced2:00remaining
Which option correctly defines a DateField that allows empty values?
You want a DateField that can be empty in the database and in forms. Which is correct?
Attempts:
2 left
💡 Hint
Remember the difference between blank and null in Django fields.
✗ Incorrect
null=True allows database to store NULL; blank=True allows form to accept empty input. Both are needed for optional DateField.
🔧 Debug
advanced2:00remaining
Why does this model raise an error on migration?
Model code:
What is the cause of the error?
class Person(models.Model):
name = models.CharField(max_length=50)
age = models.IntegerField(blank=True)
What is the cause of the error?
Attempts:
2 left
💡 Hint
Check the meaning of blank and null for IntegerField.
✗ Incorrect
IntegerField with blank=True but without null=True causes validation error because blank affects forms but null affects database storage.
🧠 Conceptual
expert2:30remaining
How does Django handle DateField input from forms when blank=True and null=True are set?
If a DateField has blank=True and null=True, what happens when a user submits an empty date in a form?
Attempts:
2 left
💡 Hint
Think about how blank and null affect form and database behavior.
✗ Incorrect
blank=True allows empty form input; null=True allows storing NULL in database. So empty input is valid and stored as NULL.