Opened 18 years ago

Closed 18 years ago

Last modified 18 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: no UI/UX: no

Description

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/row_level_perm_manipulator.py
===================================================================
--- django/contrib/admin/row_level_perm_manipulator.py  (revision 3712)
+++ django/contrib/admin/row_level_perm_manipulator.py  (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 by Chris Long, 18 years ago

Owner: changed from Adrian Holovaty to Chris Long

comment:2 by Chris Long, 18 years ago

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