Recall & Review
beginner
What is the purpose of creating a custom user model by extending AbstractUser in Django?
Extending AbstractUser allows you to add extra fields or methods to the default user model while keeping Django's built-in authentication features intact.
Click to reveal answer
beginner
Which Django setting must be updated to use a custom user model?
You must set AUTH_USER_MODEL in your settings.py to point to your custom user model, e.g., 'myapp.CustomUser'.
Click to reveal answer
intermediate
How do you add a new field, like 'age', to a custom user model extending AbstractUser?
Define the new field in your custom user model class, for example: age = models.PositiveIntegerField(null=True, blank=True).
Click to reveal answer
intermediate
Why should you create a custom user model at the start of a Django project?
Because changing the user model later is complicated and can cause database issues. Starting with a custom model gives flexibility for future changes.
Click to reveal answer
beginner
What command do you run after creating or changing a custom user model to update the database?
Run 'python manage.py makemigrations' to create migration files, then 'python manage.py migrate' to apply changes to the database.
Click to reveal answer
What base class should you extend to create a custom user model with extra fields in Django?
✗ Incorrect
AbstractUser provides the full user model with Django's authentication features, making it easy to add extra fields.
Where do you specify your custom user model in a Django project?
✗ Incorrect
AUTH_USER_MODEL tells Django which user model to use for authentication.
Which of these is a correct way to add a new field 'nickname' to a custom user model?
✗ Incorrect
A nickname is text, so CharField with max_length is appropriate.
What happens if you change the user model after running migrations without proper planning?
✗ Incorrect
Changing the user model after migrations can cause serious database and migration issues.
Which command applies database changes after modifying your custom user model?
✗ Incorrect
The migrate command applies the migration files to the database.
Explain how to create a custom user model by extending AbstractUser in Django and what steps are needed to use it.
Think about model creation, settings update, and database migration.
You got /4 concepts.
Why is it important to decide on a custom user model early in a Django project?
Consider the impact on database and project structure.
You got /4 concepts.