Re: Avoiding the ThreadLocals hack - anything new in NewForms-Admin?

2008-04-23 Thread SmileyChris

How about this:

Set your model's user field so editable=False
Sub-class ModelAdmin
Override its `save_add` method, setting form.data['user'] =
request.user then calling the super method
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Avoiding the ThreadLocals hack - anything new in NewForms-Admin?

2008-04-23 Thread AndyB

I was reading this page 
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
and was wondering how the advice on avoiding the hack applied to my
own use case.

I am using the ThreadLocals hack to get the current user in a model
when overriding the save() method. Therefore I can't pass in the user
as I can't control how save() is called.

On a higher level my goal is to limit the Admin changelist to only
show the objects associated with the current user.

I am using NewForms-Admin so was hoping that there are new ways to
achieve this but after a bit of head scratching and source-code
reading nothing has leapt out at me.


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