#21839 closed New feature (duplicate)
User Model username field
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.auth | Version: | 1.6 |
Severity: | Normal | Keywords: | custom-user-model |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I would love to see django officially use an email address as the username. It seems like a much more logical choice and would put an end to the constant questions appearing all over the internet regarding best practices when defining a custom user model as well as all the problems people have with it.
My recommendation:
- Modify the default user model to allow users to authenticate using either their username or email address. This is becoming common behavior on many popular web applications.
- Make both the username and email fields optional so users aren't required to created a username.
The benefits of this would be huge for django because it would create out-of-the-box functionality that developers actually want out of the box. As it stands now, the majority of django projects created have to immediately modify this core piece of functionality and the modification trickles through the rest of their code. It would also make more sense because email addresses are, by definition, unique and could serve as the unique identifier.
At the very least, maybe just don't define a user model and leave the abstract class in place. This would at the very least not hijack the most sensible name for the user model, "User".
I know this would likely result in some backwards incompatibility issues regarding the current method of defining a custom user model but there could be a setting made to effectively make it an opt-in feature.
I'm sure this has been said before. But it just seems like the community is screaming loudly and clearly that this is an area which needs work.
Change History (2)
comment:1 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
… and in the meantime, if you want email based authentication (or any other custom User requirements for that matter), you can define and use your own custom User model. The docs even contain a worked example for an email-based user.
The default user model will not change like this, it is too backwards incompatible. A setting to control it is not sufficient - it's further reaching than you initially imagine.
There is an intention of introducing
django.contrib.emailauth
module to provide an out of the box solution. This is ticket #20824. In the mean time there are third party applications which provide this.