summaryrefslogtreecommitdiff
path: root/tests/admin_views/admin.py
diff options
context:
space:
mode:
authorArtyom Kotovskiy <artyomkotovskiy@gmail.com>2026-04-10 00:27:14 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2026-04-22 10:13:58 -0400
commit84db026228413dda4cd195464554d51c0b208e32 (patch)
tree9d5602570a2f242a76e06c97a8bc0215a00920eb /tests/admin_views/admin.py
parent512e348bb271878a1e4f1ab6ae187a22dd16222b (diff)
Fixed #15759 -- Excluded fields by per-object permissions for ModelAdmin.list_editable.
Instead of going over all objects in a queryset and filtering by user permissions, added skipping while saving the formset so there is no need to refetch objects again.
Diffstat (limited to 'tests/admin_views/admin.py')
-rw-r--r--tests/admin_views/admin.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index 10fccca1a1..5e7a055ec3 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -377,6 +377,17 @@ class ParentWithUUIDPKNoAddAdmin(admin.ModelAdmin):
return False
+class PersonNoChangePermissionsAdmin9(admin.ModelAdmin):
+ list_display = ("name", "gender", "alive")
+ list_editable = ("gender", "alive")
+ ordering = ("id",)
+
+ def has_change_permission(self, request, obj=None):
+ if obj is None:
+ return True
+ return obj.id % 2 == 0
+
+
class FooAccountAdmin(admin.StackedInline):
model = FooAccount
extra = 1
@@ -1491,6 +1502,7 @@ class ActorAdmin9(admin.ModelAdmin):
site9 = admin.AdminSite(name="admin9")
site9.register(Article, ArticleAdmin9)
site9.register(Actor, ActorAdmin9)
+site9.register(Person, PersonNoChangePermissionsAdmin9)
site10 = admin.AdminSite(name="admin10")
site10.final_catch_all_view = False