From 4fc3629dcdf809d0af97140e2c3e429b394dc9da Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Fri, 4 Aug 2023 17:26:25 +0200 Subject: [PATCH] Fix users searchfield not working --- storage/admin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/admin.py b/storage/admin.py index 621c487..9a2c9da 100644 --- a/storage/admin.py +++ b/storage/admin.py @@ -42,7 +42,7 @@ class ItemAdmin(ModelAdminMixin, admin.ModelAdmin): inlines = [ItemImageInline] save_on_top = True autocomplete_fields = ["parent", "owner", "taken_by"] - search_fields = ["name", "owner", "taken_by"] + search_fields = ["name", "owner__name", "taken_by__name"] def formfield_for_foreignkey(self, db_field, request, **kwargs): formfield = super().formfield_for_foreignkey(db_field, request, **kwargs) @@ -106,6 +106,11 @@ class StaffProxyModelAdmin(UserAdmin): def has_add_permission(self, request, obj=None): return request.user.is_superuser + def __has_view_permission(self, request, obj=None): + return True + + has_view_permission = __has_view_permission + has_change_permission = has_add_permission has_delete_permission = has_add_permission has_module_permission = has_add_permission