In Django, how would you extend the User model to include additional fields?
- a. Subclass the User model and add your fields to the subclass.
- b. Modify the Django source code to include additional fields in the User model.
- c. Create a separate model with a one-to-one relationship to the User model to store additional fields.
- d. It's not possible to extend the User model in Django.
In Django, you can extend the User model by creating a separate model with a one-to-one relationship to the User model to store additional fields. This approach maintains the integrity of the User model. Options a and b are not recommended as they can lead to issues during migrations and upgrades. Option d is incorrect.
Loading...
Related Quiz
- How can you view the list of variables and their values in the current scope while debugging with Pdb?
- How do you define a floating-point variable in Python?
- You are developing a test suite using the unittest framework and need to share the same setup code across multiple test cases. Which method would you use?
- How would you optimize the space complexity of a dynamic programming algorithm?
- What is the time complexity of checking the membership of an element in a set in Python?