TokenAdmin: add 'user' to autocomplete_fields (#6762)

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.
This commit is contained in:
Jan Pieter Waagmeester 2019-06-28 14:44:15 +02:00 committed by Tom Christie
parent f76480a127
commit cfd3ea0996

View File

@ -7,6 +7,7 @@ class TokenAdmin(admin.ModelAdmin):
list_display = ('key', 'user', 'created') list_display = ('key', 'user', 'created')
fields = ('user',) fields = ('user',)
ordering = ('-created',) ordering = ('-created',)
autocomplete_fields = ('user',)
admin.site.register(Token, TokenAdmin) admin.site.register(Token, TokenAdmin)