We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Getting the most out of Django’s User Model

Formal Metadata

Title
Getting the most out of Django’s User Model
Title of Series
Part Number
27
Number of Parts
48
Author
Contributors
License
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Django’s User model is nice, but the fields it provides out of the box are minimal. We frequently need to associate our own custom data with a user, and luckily Django provides ways for us to add to its built-in User model. This talk will help novice Django developers understand which options are best when it comes to getting the most out of the Django User model. I’ll start by talking about the built-in Django User model and what it has to offer. Then I will identify scenarios when the User model might not be enough for a project, and why someone might want something with more flexibility. Then we’ll look at the different ways to get the most out of the Django User model. There are two main methods I’ll cover: Extending the User model Creating a custom User model Extending the User model: Extending the User model is handy when you only need to add a few extra fields. There are two main ways to do this: using a proxy model, and using a OneToOneField. I will cover the pros and cons of each, and give examples for implementing each. Creating a custom User model: With this method, you can substitute Django’s default User model with your own. Though more complex, a custom User model is particularly useful when you need to uniquely identify users by email address instead of by username. I’ll go into a couple more scenarios where a custom User model would be helpful, and show examples of implementation. Lastly, I will show how each method works with the default Django admin, and how they can be managed there.