Skip to content

Commit 4842ad1

Browse files
authored
Add username search field for TokenAdmin (#8927) (#8934)
* Add username search field for TokenAdmin (#8927) * Sort imports in a proper order (#8927)
1 parent 959085c commit 4842ad1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

rest_framework/authtoken/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.contrib.auth import get_user_model
55
from django.core.exceptions import ValidationError
66
from django.urls import reverse
7+
from django.utils.translation import gettext_lazy as _
78

89
from rest_framework.authtoken.models import Token, TokenProxy
910

@@ -23,6 +24,8 @@ def url_for_result(self, result):
2324
class TokenAdmin(admin.ModelAdmin):
2425
list_display = ('key', 'user', 'created')
2526
fields = ('user',)
27+
search_fields = ('user__username',)
28+
search_help_text = _('Username')
2629
ordering = ('-created',)
2730
actions = None # Actions not compatible with mapped IDs.
2831
autocomplete_fields = ("user",)

0 commit comments

Comments
 (0)