mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
cfd3ea0996
TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the [ModelAdmin.autocomplete_fields](https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields) option to use select2 to provide a better user experience. If support for django 1.11 is dropped, this change would make the `TokenAdmin` usable again.
14 lines
297 B
Python
14 lines
297 B
Python
from django.contrib import admin
|
|
|
|
from rest_framework.authtoken.models import Token
|
|
|
|
|
|
class TokenAdmin(admin.ModelAdmin):
|
|
list_display = ('key', 'user', 'created')
|
|
fields = ('user',)
|
|
ordering = ('-created',)
|
|
autocomplete_fields = ('user',)
|
|
|
|
|
|
admin.site.register(Token, TokenAdmin)
|