2
What I did
I have a view that calls a template with a form. In a given case, I need to save some data in the session scope and send it to another url - which will call another view and another template.
My Problem
I created the session and redirected it to the URL. This URL is pointing to MinhaSegundaView
, calling a different form and template. I ran a test and displayed the session data in the template using the syntax session.order_id
, and wanted to do the same in my form FormDois
, because I use it to build inputs in the template. However, if I do initial
the request
, he says that this element does not exist. I believe because he does not have access to the request object.
What can I do ?
My Code
Views.py
class MinhaView()
template_name = 'arquivo.html'
form_class = FormUm
def post()
request.session['order_id'] = order_id
HttpResponseRedirect(reverse('url_email'))
class MinhaSegundaView()
template_name = 'arquivodois.html'
form_class = FormDois
class FormDois(forms.Form):
order_id = forms.CharField(label=u'Pedido', initial=request.session['order_id'], required=True)