#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
-------------------------------------+-------------------------------------
     Reporter:  Jonas Dittrich       |                    Owner:
                                     |  Abderrahmane MELEK
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.auth         |                  Version:  5.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

 * has_patch:  1 => 0
 * needs_better_patch:  1 => 0
 * summary:  USERNAME_FIELD must be unique in order to use createsuperuser
     command =>
     createsuperuser validation breaks if USERNAME_FIELD is distinct but
     user manager deliberately lacks get_by_natural_key()
 * type:  Cleanup/optimization => Bug

Comment:

 Reopened #35729 as a usability issue in the serialization framework that
 model subclasses cannot opt out of natural key serialization.

 This issue was opened after OP bit the bullet and reimplemented the User
 model from scratch. I agree it's not correct for createsuperuser to deduce
 from `field.unique` that you can `get_by_natural_key()`, since there could
 be a use case for omitting an implementation as doc'd:

 > Conversely, if (for some strange reason) you want Django to output
 natural keys during serialization, but not be able to load those key
 values, just don’t define the get_by_natural_key() method.

 "strange" or not, given we've doc'd it, I think it's reasonable for
 `createsuperuser` to catch `AttributeError`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:11>
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/01070199818811e1-ce1f4266-0e89-4996-b571-3cea9c5bde0a-000000%40eu-central-1.amazonses.com.

Reply via email to