Red User, Blue User, MyUser, auth.User

By Russell Keith-Magee

Elevator Pitch

Django’s contrib.auth framework allows to you specify a custom user model. Why does this matter? When should you use a custom user model? And how do you live with it once you’ve got one?

Description

Django’s contrib.auth is a key part of most Django websites. However, there are some important details you need to understand if you’re going to make good use of custom user models. Some of these details are technical - for example, custom user models require some special consideration when interacting with migrations.

But even more important are the details about why custom user models are important in the first place. Custom User models were neccessary to break some really common anti-patterns about user identity - anti-patterns that are baked into Django’s default user model, and are extraordinarily common in the wider web development world.

In this talk, you’ll learn about user identity: what it means, and what you have to think about when you’re developing the user modelling parts of your Django project. You’ll also learn how to use Django’s custom user model in practice.

Notes

This is a revised version of a talk I gave at DjangoCon US 2013 in Chicago. At that time, custom user models were a brand new feature. However, this talk is one of the talks that I am most frequently asked for a link to, because of the content about naming and identity. There have been some significant changes in Django since custom user models were introduced - most notably Migrations - so I believe there would be benefit in re-visiting this content.