From 0f66297b77ec735fda4cec7a6c0ce35ef8f587ff Mon Sep 17 00:00:00 2001 From: Mounir Date: Mon, 5 Nov 2018 23:07:17 +0100 Subject: [PATCH] Use raw_id_fields to avoid selecting all users In most applications, there are many users, this will lead to a non performant admin page if you want to modify or add a new token. --- rest_framework/authtoken/admin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rest_framework/authtoken/admin.py b/rest_framework/authtoken/admin.py index 1a507249b..d269fb0a4 100644 --- a/rest_framework/authtoken/admin.py +++ b/rest_framework/authtoken/admin.py @@ -3,10 +3,9 @@ from django.contrib import admin from rest_framework.authtoken.models import Token +@admin.register(Token) class TokenAdmin(admin.ModelAdmin): list_display = ('key', 'user', 'created') fields = ('user',) ordering = ('-created',) - - -admin.site.register(Token, TokenAdmin) + raw_id_fields = ('user',)