Skip to content

Commit

Permalink
Add username search field for TokenAdmin (#8927) (#8934)
Browse files Browse the repository at this point in the history
* Add username search field for TokenAdmin (#8927)

* Sort imports in a proper order (#8927)
  • Loading branch information
rnv812 authored Apr 8, 2023
1 parent 959085c commit 4842ad1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rest_framework/authtoken/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from rest_framework.authtoken.models import Token, TokenProxy

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

0 comments on commit 4842ad1

Please sign in to comment.