I had a similar requirement for a current project. Users in the admin
needed to be able to see ONLY the objects that they had created.

My solution was:
1) http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
2) Add foreign key to model to track which user created the object.
3) Use the ThreadLocals trick with a custom save() to set the user
(Objects created via command line get assigned the first superuser in
the DB)
4) A smart manager that is now aware of the current logged in user
thanks to the ThreadLocals middleware and can use that to limit
requests. (displaying all if superuser, or if run using python
manage.py shell)

I'm sure this approach could be expanded to use namespaces/groups
instead of user on the model's foreign key. To my mind at least, it's
a little easier to follow what's going on than overriding various
methods in admin.py

~Justin
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to