Re: [Django] #36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user manager deliberately lacks get_by_natural_key()

5 views
Skip to first unread message

Django

unread,
May 18, 2026, 7:38:49 PM (12 days ago) May 18
to django-...@googlegroups.com
#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
--------------------------------+---------------------------------------
Reporter: Jonas Dittrich | Owner: Joe Babbitt
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 Joe Babbitt):

* owner: Abderrahmane MELEK => Joe Babbitt

Comment:

Picking up as part of the Pycon 2026 Django Sprint!

(Assuming that Abderrahmane does not want to pick up the code change since
we are no longer making a doc only change)
--
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 19, 2026, 2:29:36 PM (11 days ago) May 19
to django-...@googlegroups.com
#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
--------------------------------+---------------------------------------
Reporter: Jonas Dittrich | Owner: Joe Babbitt
Type: Bug | 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
--------------------------------+---------------------------------------
Changes (by Joe Babbitt):

* has_patch: 0 => 1

Comment:

Patch has been submitted via GitHub. My approach was to copy what we do
with `username_is_unique` and create a cached_property. I think the cached
bit is a fair trade-off, especially helping folks who don't implement
natural keys since [https://stackoverflow.com/questions/903130/hasattr-vs-
try-except-block-to-deal-with-non-existent-attributes it appears] the
negative result of a `has_attr` lookup is slower than a positive result.
--
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:13>

Django

unread,
May 28, 2026, 2:16:33 PM (2 days ago) May 28
to django-...@googlegroups.com
#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
-------------------------------------+-------------------------------------
Reporter: Jonas Dittrich | Owner: Joe
| Babbitt
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:14>

Django

unread,
May 28, 2026, 2:32:06 PM (2 days ago) May 28
to django-...@googlegroups.com
#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
-------------------------------------+-------------------------------------
Reporter: Jonas Dittrich | Owner: Joe
| Babbitt
Type: Bug | Status: closed
Component: contrib.auth | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"2c8c0ca0a0b73b167c29db506f810c318f915587" 2c8c0ca]:
{{{#!CommitTicketReference repository=""
revision="2c8c0ca0a0b73b167c29db506f810c318f915587"
Fixed #36225 -- Coped with lack of get_by_natural_key() in
createsuperuser.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:15>

Django

unread,
May 28, 2026, 2:32:51 PM (2 days ago) May 28
to django-...@googlegroups.com
#36225: createsuperuser validation breaks if USERNAME_FIELD is distinct but user
manager deliberately lacks get_by_natural_key()
-------------------------------------+-------------------------------------
Reporter: Jonas Dittrich | Owner: Joe
| Babbitt
Type: Bug | Status: closed
Component: contrib.auth | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"865384f96cc588b2babe747d192771ffea07c991" 865384f9]:
{{{#!CommitTicketReference repository=""
revision="865384f96cc588b2babe747d192771ffea07c991"
[6.1.x] Fixed #36225 -- Coped with lack of get_by_natural_key() in
createsuperuser.

Backport of 2c8c0ca0a0b73b167c29db506f810c318f915587 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36225#comment:16>
Reply all
Reply to author
Forward
0 new messages