#36225: USERNAME_FIELD must be unique in order to use createsuperuser command
-------------------------------------+-------------------------------------
     Reporter:  Jonas Dittrich       |                    Owner:
         Type:                       |  Abderrahmane MELEK
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.auth         |                  Version:  5.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):

 The plan from comment:3 to tweak the docs gives me pause, since this use
 case was explicitly
 
[https://github.com/django/django/blob/4e7a991c12a113229e0927974d3bf94ea04eecf6/tests/auth_tests/models/invalid_models.py#L5
 tested] and added in #24910.

 From my reading of the forum post, the two sharp edges that came up for
 the implementer were:
 - reimplementing `AbstractBaseUser` from scratch to avoid having to `del
 AbstractBaseUser.natural_key` to support serialization
 - createsuperuser's username validation not being aware of `null=True,
 distinct=True` username fields

 We could tweak the docs instead to explain that `natural_key` must be
 overridden on the model. The use case for nullable usernames and the
 attendant weirdness around having to override `get_by_natural_key` on the
 manager doesn't seem worth documenting to me: it could just be implicit
 from the advice to "override".
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:8>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701991622d866-ff11d1be-2af0-4b92-a1d8-5c995f0618b2-000000%40eu-central-1.amazonses.com.

Reply via email to