James,
Thanks, this is great. I never made this connection before. I have
been using threadlocals for a while (to implement a custom manager
with role-based access). Since the start I have been passing a users
role as a kw argument in to the Manager via the shell for testing, and
until
On Mon, May 19, 2008 at 4:10 PM, Tim Chase
<[EMAIL PROTECTED]> wrote:
> It's the last bit that can throw folks...many folks seem to use
> very nice/helpful bits of the framework that abstract the save()
> call so it's never thought-about. Wouldn't adding a parameter to
> save() stymie the admin a
>> how do you pass the request object to models?
>
> Same way you pass any argument to any function or method in
> Python: write your function/method to accept the argument, and
> pass it from the code that calls the function/method.
It's the last bit that can throw folks...many folks seem to us
On May 19, 5:35 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
> -richard
>
Thanks!, it works
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django us
On Mon, May 19, 2008 at 3:45 PM, Richard Dahl <[EMAIL PROTECTED]> wrote:
> how do you pass the request object to models?
Same way you pass any argument to any function or method in Python:
write your function/method to accept the argument, and pass it from
the code that calls the function/method.
how do you pass the request object to models?
-richard
On 5/19/08, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On Mon, May 19, 2008 at 3:24 PM, enri57ar <[EMAIL PROTECTED]> wrote:
> > How access to request object within models ?
>
> Pass it as an argument the same as any other value. Magical
On Mon, May 19, 2008 at 3:24 PM, enri57ar <[EMAIL PROTECTED]> wrote:
> How access to request object within models ?
Pass it as an argument the same as any other value. Magical hacks to
try to make it available otherwise are likely to land you in trouble
later on.
--
"Bureaucrat Conrad, you are
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
-richard
On 5/19/08, enri57ar <[EMAIL PROTECTED]> wrote:
>
>
> How access to request object within models ?
>
>
> from django.contrib.auth.models import User
>
> Class Message(models.Model):
>message = ...
>user_id = models.Fo
How access to request object within models ?
from django.contrib.auth.models import User
Class Message(models.Model):
message = ...
user_id = models.ForeignKey(User)
def save(self):
user_id = request.user.id # doesn't work
super(Mensaje, self).save()
--~--~---
9 matches
Mail list logo