mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
* Add username search field for TokenAdmin (#8927) * Sort imports in a proper order (#8927)
This commit is contained in:
parent
959085c145
commit
4842ad1b6a
|
@ -4,6 +4,7 @@ from django.contrib.admin.views.main import ChangeList
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from rest_framework.authtoken.models import Token, TokenProxy
|
from rest_framework.authtoken.models import Token, TokenProxy
|
||||||
|
|
||||||
|
@ -23,6 +24,8 @@ class TokenChangeList(ChangeList):
|
||||||
class TokenAdmin(admin.ModelAdmin):
|
class TokenAdmin(admin.ModelAdmin):
|
||||||
list_display = ('key', 'user', 'created')
|
list_display = ('key', 'user', 'created')
|
||||||
fields = ('user',)
|
fields = ('user',)
|
||||||
|
search_fields = ('user__username',)
|
||||||
|
search_help_text = _('Username')
|
||||||
ordering = ('-created',)
|
ordering = ('-created',)
|
||||||
actions = None # Actions not compatible with mapped IDs.
|
actions = None # Actions not compatible with mapped IDs.
|
||||||
autocomplete_fields = ("user",)
|
autocomplete_fields = ("user",)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user