Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2652 closed defect (fixed)

[patch] [per-object-permissions] changing perms fails if another app has model called 'user' or 'group'

Reported by: mattimustang@… Owned by: Chris Long
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


My application has a model called Group so editing row level perms fails because the ContentType lookup is not specific enough.

Patch below fixes it.

Index: django/contrib/admin/
--- django/contrib/admin/  (revision 3712)
+++ django/contrib/admin/  (working copy)
@@ -144,7 +144,7 @@
     def returnObject(data):
         data = data.split('-')
-        ct = ContentType.objects.get(model__exact=data[0])
+        ct = ContentType.objects.get(app_label='auth', model__exact=data[0])
         obj = ct.get_object_for_this_type(pk=data[1])
         return obj
@@ -157,4 +157,4 @@
     returnKey = staticmethod(returnKey)
\ No newline at end of file

Change History (2)

comment:1 Changed 12 years ago by Chris Long

Owner: changed from Adrian Holovaty to Chris Long

comment:2 Changed 12 years ago by Chris Long

Resolution: fixed
Status: newclosed

(In [3716]) [per-object-permissions] Fixes #2652, modified the form field to include the app label in the select field (the elements of which are now separated by a /)

Note: See TracTickets for help on using tickets.
Back to Top