[Django] #21839: User Model username field

6 views
Skip to first unread message

Django

unread,
Jan 21, 2014, 8:54:49 AM1/21/14
to django-...@googlegroups.com
#21839: User Model username field
------------------------------+-------------------------------
Reporter: davegunnoe@… | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: 1.6
Severity: Normal | Keywords: custom-user-model
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+-------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21839>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 21, 2014, 9:43:57 AM1/21/14
to django-...@googlegroups.com
#21839: User Model username field
-----------------------------------+--------------------------------------
Reporter: davegunnoe@… | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: 1.6
Severity: Normal | Resolution: duplicate

Keywords: custom-user-model | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by mjtamlyn):

* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21839#comment:1>

Django

unread,
Jan 21, 2014, 6:31:54 PM1/21/14
to django-...@googlegroups.com
#21839: User Model username field
-----------------------------------+--------------------------------------
Reporter: davegunnoe@… | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: 1.6
Severity: Normal | Resolution: duplicate

Keywords: custom-user-model | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by russellm):

… 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
[https://docs.djangoproject.com/en/dev/topics/auth/customizing/#specifying-a
-custom-user-model custom User model]. The docs even contain
[https://docs.djangoproject.com/en/dev/topics/auth/customizing/#a-full-
example a worked example for an email-based user.]

--
Ticket URL: <https://code.djangoproject.com/ticket/21839#comment:2>

Reply all
Reply to author
Forward
0 new messages