Opened 14 years ago
Closed 14 years ago
#16064 closed New feature (duplicate)
auth's User model should be fully customizable - another way of providing additional information about users
Reported by: | fas | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.3 |
Severity: | Normal | Keywords: | user email login authentication backend profile |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current way of adding additional user information is to create a user profile model:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
The way this is handled now is very unsatisfying. It makes not much sense to have the fields of the User model fixed/dictated by Django and to have to create a related model to store additional user information. Having multiple tables for basic user information is not the usual way of storing user information and would not be done if it were not for the restriction that Django has.
Another issue new Django users face often: if they want the users to login via e-mail address and not via username, they hit a wall. Custom authentication backends that can be found are all defective, mainly due to the fact that the email field is not declared unique. Monkey patching it is not a great option.
I propose the following solution:
If settings.AUTH_USER_MODEL is defined, this model should be used instead of auth.models.User. This model should inherit from auth.models.User.
This way, one can define all relevant fields to the application (instead of having them in a separate related model) and also redefine the email field to be unique if one wishes to do so.
I think this would be a vastly superior way of adding additional user information.
If settings.AUTH_USER_MODEL is not defined, everything can work as before.
I think this would improve Django's auth contrib module significantly. What do you think?
I'm closing this as a duplicate because discussions on this topic are already underway, and have been for some time.
Here are some current threads on the topic:
https://groups.google.com/d/topic/django-developers/Xd7_PhJhRUg/discussion
https://groups.google.com/d/topic/django-developers/XvUAX8B27qg/discussion
https://groups.google.com/d/topic/django-developers/1Xj8Zzdokrw/discussion
For a ticket to be valid it should result from discussion on django-developers and a consensus there.