How do you implement custom user authentication in Django?
Instruction: Explain the steps involved in implementing custom user authentication in Django.
Context: This question assesses the candidate's understanding of Django's authentication system and their ability to customize it according to specific requirements.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
First distinguish storing extra user data from changing how credentials are verified. Adding a profile or an AbstractUser field does not itself require a custom authentication backend. For a new project, choose the user model and set AUTH_USER_MODEL before the first migrations; changing it in an established database needs an explicit data/schema migration plan.
If a unique email or phone identifier is sufficient, a correctly implemented custom model with the appropriate USERNAME_FIELD, manager and forms may still use...