filtered admin change-list

40 views
Skip to first unread message

omerd

unread,
Mar 17, 2012, 7:07:43 PM3/17/12
to Django users
Hi,

I want to be able to show parts of the change list, by the user that
view it.
The case is that every super-user can create instances of a certain
model. I wan't that in the change-list page of that model in the admin
site, every user will see only the instances that he'd created. Of
course, this user doesn't have permissions to view or edit instances
of other users.

What is the best approach to accomplish this?

Rajeesh Nair

unread,
Mar 19, 2012, 1:26:58 PM3/19/12
to django...@googlegroups.com

Add a field on your model to identify the user who created each instance & then extend your model_admin's queryset method to filter queryset by the user.

omerd

unread,
Mar 23, 2012, 5:21:55 AM3/23/12
to Django users
thank you. I will try it

Marc Aymerich

unread,
Mar 23, 2012, 5:33:19 AM3/23/12
to django...@googlegroups.com

take a look at this project:
https://github.com/lukaszb/django-guardian

or search in google by: django admin row level permission
--
Marc

omerd

unread,
Mar 24, 2012, 5:34:52 PM3/24/12
to Django users
thank you, it worked. I wrote queryset, has_change_permission and
save_model in my ModelAdmin.
As i see it, django-guardian intended for low level permissions in the
web application itself, not the admin-interface.

By the way, is it safe and secure to allow any user (which is not
superuser and is not trusted) to log in the admin interface (by
marking every new user as 'is_staff'=True) when restricting his
permissions to change only the objects he owns?
Reply all
Reply to author
Forward
0 new messages