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 <felli...@gmail.com>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 __init__(self, *args, **kwargs): > profile = kwargs.pop('vUserProfile', None) > super(PedidoItensForm, self).__init__(*args, **kwargs) > self.fields["idproduto"].queryset = > Produto.objects.filter(idempresa=profile.idempresa) > > I need to pass UserProfile to my form, to get works my filter. > > If I use inlineformset_factory, how can I pass the vUserProfile ? > > > Thanks > > T.·.F.·.A.·. S+F > *Fellipe Henrique P. Soares* > > *"Quemadmodum gladius neminem occidit, occidentis telum est."* (Epistulae > morales ad > Lucilium<http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>, > Lucius Annaeus Seneca) > > *"Any intelligent fool can make things bigger, more complex, and more > violent. It takes a touch of genius -- and a lot of courage -- to move in > the opposite direction."* > Albert Einstein (March 14th 1879 – April 18th 1955) > > > 2013/1/22 Tomas Neme <lacrymol...@gmail.com> > >> >> >> 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 <whalb...@gmail.com> wrote: >> >>> 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 >>> https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-data-in-templates >>> >>> >>> >>> On Jan 22, 8:34 pm, Fellipe Henrique <felli...@gmail.com> wrote: >>> > 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* >>> > >>> > *"Quemadmodum gladius neminem occidit, occidentis telum est."* >>> (Epistulae >>> > morales ad Lucilium< >>> http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>, >>> > Lucius Annaeus Seneca) >>> > >>> > *"Any intelligent fool can make things bigger, more complex, and more >>> > violent. It takes a touch of genius -- and a lot of courage -- to move >>> in >>> > the opposite direction."* >>> > Albert Einstein (March 14th 1879 – April 18th 1955) >>> >>> -- >>> 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 >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> >> >> -- >> "The whole of Japan is pure invention. There is no such country, there >> are no such people" --Oscar Wilde >> >> |_|0|_| >> |_|_|0| >> |0|0|0| >> >> (\__/) >> (='.'=)This is Bunny. Copy and paste bunny >> (")_(") to help him gain world domination. >> >> -- >> 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 >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.