Skip to content

Commit fb633f4

Browse files
committed
Updates for TokenAdmin.
- Respect USERNAME_FIELD of the user model. - Default ordering by username. - Filter by creation date.
1 parent 365d409 commit fb633f4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rest_framework/authtoken/admin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ def url_for_result(self, result):
2323

2424
class TokenAdmin(admin.ModelAdmin):
2525
list_display = ('key', 'user', 'created')
26+
list_filter = ('created',)
2627
fields = ('user',)
27-
search_fields = ('user__username',)
28+
search_fields = ('user__%s' % User.USERNAME_FIELD,)
2829
search_help_text = _('Username')
29-
ordering = ('-created',)
30+
ordering = ('user__%s' % User.USERNAME_FIELD,)
3031
actions = None # Actions not compatible with mapped IDs.
3132

3233
def get_changelist(self, request, **kwargs):

0 commit comments

Comments
 (0)