Re: Can I set a "global" variable after user login, to use in my view?

2013-01-31 Thread Tom Evans
On Tue, Jan 22, 2013 at 8:01 PM, Fellipe Henrique wrote: > The problem is, I need to pass this request.user to one form, using a > inlineformset_factory..in these code: > > class PedidoItensForm(ModelForm): > class Meta: > model = ItensPedido > > def

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-23 Thread Tomas Neme
> I don`t understand that.. in my form, I don't have the request, or I have? > > I know I have request in my view, but I need to pass UserProfile to my form, > but inlineformset_factory doesn't accept to pass vUserProfile as parameter, > even I modified __init__ to get this parameter. OK, so

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-23 Thread Fellipe Henrique
I don`t understand that.. in my form, I don't have the request, or I have? I know I have request in my view, but I need to pass UserProfile to my form, but inlineformset_factory doesn't accept to pass vUserProfile as parameter, even I modified __init__ to get this parameter. Here is my form

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
vUserProfile=request.user.profile or vUserProfile=request.user.get_profile() to be more flexible On Tue, Jan 22, 2013 at 5:01 PM, Fellipe Henrique wrote: > The problem is, I need to pass this request.user to one form, using a > inlineformset_factory..in these code: > >

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Fellipe Henrique
The problem is, I need to pass this request.user to one form, using a inlineformset_factory..in these code: class PedidoItensForm(ModelForm): class Meta: model = ItensPedido def __init__(self, *args, **kwargs): profile = kwargs.pop('vUserProfile', None)

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
what mengu says is good for templates, but not so for views. But lo! your request should have a .user property that points to the currently logged user, so try request.user in your view On Tue, Jan 22, 2013 at 4:49 PM, Mengu wrote: > hi fellipe, > > if you enable auth

Re: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Mengu
hi fellipe, if you enable auth context processors and pass in RequestContext to render_to_response you can always access the user in your templates which also means you can access the associated profile as user.profile (assuming your model is named profile) please read more at

Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Fellipe Henrique
Hello, It's possible, when the user make a login, I set one "global" variable, and get this value in my view? My question is because I have a inlineformset_factory, and I need to pass a user profile do my view.. but it`s doesn't work. Regards, T.·.F.·.A.·. S+F *Fellipe Henrique P. Soares*