[Django] #28089: Remove requirement of get_short_name and get_full_name for subclasses of AbstractBaseUser

8 views
Skip to first unread message

Django

unread,
Apr 17, 2017, 5:12:44 PM4/17/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name and get_full_name for subclasses of
AbstractBaseUser
-----------------------------------------+------------------------
Reporter: Josh Schneier | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Since `USERNAME_FIELD` became required and the corresponding
`get_username` now always exists it doesn't make much sense to me to
require the implementation of these 2 methods. They are only used once
each in fairly inconsequential parts of the admin (history in addition to
username for `get_full_name` and the greetings in the header block for
`get_short_name`). All other methods are concrete and generally
applicable. I do think we should still leave them in `AbstractUser`.

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

Django

unread,
Apr 18, 2017, 1:56:05 PM4/18/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name and get_full_name for subclasses of
AbstractBaseUser
-------------------------------------+-------------------------------------

Reporter: Josh Schneier | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.auth | Version: master
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
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Uncategorized => Cleanup/optimization


Comment:

Do you have any code changes is mind or would this be a documentation
clarification? I'm not sure what "removing the requirement" looks like.

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

Django

unread,
Apr 18, 2017, 3:30:39 PM4/18/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name and get_full_name for subclasses of
AbstractBaseUser
-------------------------------------+-------------------------------------

Reporter: Josh Schneier | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.auth | Version: master
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 Josh Schneier):

Currently in `AbstractBaseUser` they raise `NotImplementedError`, I would
remove those definitions.

Actually what do you think of simply removing `get_short_name` and
`get_full_name` altogether? They feel like legacy warts to me given the
custom user model. We can just use the `__str__` of the user where
appropriate (currently `get_username()` everywhere).

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

Django

unread,
Apr 19, 2017, 9:50:12 AM4/19/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name() and get_full_name() for subclasses
of AbstractBaseUser
--------------------------------------+------------------------------------

Reporter: Josh Schneier | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
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 Tim Graham):

* stage: Unreviewed => Accepted


Comment:

Removing the definitions in `AbstractBaseUser` that raise
`NotImplementedError` might be reasonable. As far as I see, the admin
would work without them:

`{% firstof user.get_short_name user.get_username %}`
(from `contrib/admin/templates/admin/base.html`)

`<td>{{ action.user.get_username }}{% if action.user.get_full_name %} ({{
action.user.get_full_name }}){% endif %}</td>`
(from `contrib/admin/templates/admin/object_history.html`)

Currently, if a subclass doesn't want to use those methods, it has to
define them to return an empty value to suppress the `NotImplementedError`
exceptions while rendering those admin templates.

Documentation updates as well as a mention in the release notes for third-
party apps that might expect those methods to exist are also required.

--
Ticket URL: <https://code.djangoproject.com/ticket/28089#comment:3>

Django

unread,
Apr 19, 2017, 1:08:38 PM4/19/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name() and get_full_name() for subclasses
of AbstractBaseUser
-------------------------------------+-------------------------------------
Reporter: Josh Schneier | Owner: Josh
Type: | Schneier
Cleanup/optimization | Status: assigned
Component: contrib.auth | Version: master

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 Josh Schneier):

* status: new => assigned
* owner: nobody => Josh Schneier
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8377 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28089#comment:4>

Django

unread,
May 6, 2017, 5:25:02 PM5/6/17
to django-...@googlegroups.com
#28089: Remove requirement of get_short_name() and get_full_name() for subclasses
of AbstractBaseUser
-------------------------------------+-------------------------------------
Reporter: Josh Schneier | Owner: Josh
Type: | Schneier
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"5df0ff4155d2ee3192768e8f7f75b546f98c3f77" 5df0ff4]:
{{{
#!CommitTicketReference repository=""
revision="5df0ff4155d2ee3192768e8f7f75b546f98c3f77"
Fixed #28089 -- Removed requirement to implement get_short_name() and
get_full_name() in AbstractBaseUser subclasses.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28089#comment:5>

Reply all
Reply to author
Forward
0 new messages