I need to set a variable on session, when a user login happens. How can I do this?
if request.user.is_authenticated():
profile = request.user.get_profile()
request.session['idempresa'] = profile.idempresa
My other question is in a form:
class PedidoItensForm(ModelForm):
class Meta:
model = ItensPedido
def __init__(self, *args, **kwargs):
profile = kwargs.pop('vUserProfile', None)
super(PedidoItensForm, self).__init__(*args, **kwargs)
How can I get the "idempresa" value of session, to use in my queryset?
See Question&Answers more detail:os