From d1ecfb30ad8a859fe3c64cbf371cafa8ca29c964 Mon Sep 17 00:00:00 2001 From: Ema Ciupe Date: Wed, 18 Sep 2024 18:45:24 +0300 Subject: [PATCH] Admin: raw id for user on auth Token model --- src/etools/applications/users/admin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/etools/applications/users/admin.py b/src/etools/applications/users/admin.py index d8b18644a..3b0fac10b 100644 --- a/src/etools/applications/users/admin.py +++ b/src/etools/applications/users/admin.py @@ -23,6 +23,8 @@ from django_tenants.admin import TenantAdminMixin from django_tenants.postgresql_backend.base import FakeTenant from django_tenants.utils import get_public_schema_name +from rest_framework.authtoken.admin import TokenAdmin +from rest_framework.authtoken.models import TokenProxy from unicef_snapshot.admin import ActivityInline, SnapshotModelAdmin from etools.applications.funds.tasks import sync_all_delegated_frs, sync_country_delegated_fr @@ -531,6 +533,10 @@ def has_change_permission(self, request, obj=None): return False +class CustomTokenAdmin(TokenAdmin): + raw_id_fields = ('user',) + + # Re-register UserAdmin admin.site.register(get_user_model(), UserAdminPlus) admin.site.register(UserProfile, ProfileAdmin) @@ -538,3 +544,7 @@ def has_change_permission(self, request, obj=None): admin.site.register(WorkspaceCounter) admin.site.register(Realm, RealmAdmin) admin.site.register(StagedUser, StagedUserAdmin) + + +admin.site.unregister(TokenProxy) +admin.site.register(TokenProxy, CustomTokenAdmin)