From a7a68150f144231a6d94ffb8abf6d084bb755d43 Mon Sep 17 00:00:00 2001 From: Hugo Rodger-Brown Date: Tue, 13 Sep 2022 16:55:23 +0100 Subject: [PATCH] Update authtoken admin to make "user" a raw_id_field If you have a large number of users this page will attempt to load your entire User model dataset into a select box, which will likely time out / crash the admin site. --- rest_framework/authtoken/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_framework/authtoken/admin.py b/rest_framework/authtoken/admin.py index b359e4cfe..6aaa37e2c 100644 --- a/rest_framework/authtoken/admin.py +++ b/rest_framework/authtoken/admin.py @@ -22,6 +22,7 @@ class TokenChangeList(ChangeList): class TokenAdmin(admin.ModelAdmin): list_display = ('key', 'user', 'created') + raw_id_fields = ('user',) fields = ('user',) ordering = ('-created',) actions = None # Actions not compatible with mapped IDs.