#24910: createsuperuser in interactive mode assumes USERNAME_FIELD is unique
------------------------------+--------------------------------------
     Reporter:  carljm        |                    Owner:  nobody
         Type:  Bug           |                   Status:  new
    Component:  contrib.auth  |                  Version:  1.8
     Severity:  Normal        |               Resolution:
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------

Comment (by carljm):

 Yes, there is currently some documentation stating that `USERNAME_FIELD`
 must be a unique field.

 However, the auth checks have clearly been written with the intent to
 allow a non-unique `USERNAME_FIELD`, as long as you are using a custom
 authentication backend. That's why there is both `auth.E003` and
 `auth.W004`. The former is an error, raised if you have a non-unique
 `USERNAME_FIELD` and you are using the default authentication backend
 (which requires `USERNAME_FIELD` to be unique). The latter is merely a
 warning, raised if you have a non-unique `USERNAME_FIELD` and are using a
 custom authentication backend; the warning just reminds you that you need
 to ensure your custom backend can handle non-unique `USERNAME_FIELD` in
 some appropriate way.

 I don't think there is any reason not to allow the latter usage, for
 advanced and unusual cases. So I think that a) `createsuperuser` should be
 updated to only enforce uniqueness if the field is actually unique, and b)
 the `USERNAME_FIELD` doc you linked should be updated to clarify that a
 non-unique `USERNAME_FIELD` is permissible as long as you are using a
 custom auth backend that can handle it.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.8a30e3a4e1b55a3c68ac502afb382f33%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to