In order to create a new user model in Django 1.5.x, there are two approaches:
- Inherit
AbstractUser
class which is the default user model you get, this way you can extend it with any attributes you want. However, if you want to remove any field, it's technically possible but not recommended; even if it can be done, it is against OOP principles, I believe. So if you would like to alter the current user model, there is the second approach. - Inherit
AbstractBaseUser
, which by looking at the code provides very basic functionality. You will miss all the goodness of permissions, profile retrieval and absolute url construction, unless you copy it from the default Django user model.
The above is my understanding of the situation. Correct me if I'm wrong, but doesn't this mean that if I want to simply remove the username
field out of the model since I won't need it at all, I have to copy paste the model code provided in the framework and inherit from AbstractBaseUser
and PermissionsMixin
? For such a simple thing, this approach doesn't look very pretty to me, and it looks a bit odd since I'm quite certain the custom user model was introduced largely because of the popular use case of email
field as the user identifier instead of username
.
Your thoughts (and corrections) please.