EDIT: FWIW, I am running django 1.3
I have…
class CreateProductWizard(FormWizard):
def get_template(self, step):
if step == 1:
return 'product/form_wizard/editor.html'
else:
return 'product/form_wizard/wizard_%s.html' % step
def process_step(self, request, form, step):
if step == 1:
self.extra_context = {'ptype': form.cleaned_data}
return
else:
return
def done(self, request, form_list):
# now that it's all together, store it.
return render_to_response('product/form_wizard/done.html',
{'form_data': [form.cleaned_data for form in form_list]},
context_instance=RequestContext(request))
and I’d like to get the self.extra_context to the template.
How do I get that on the template?
I’ve tried on the template:
{{extra_context}}
{{form.extra_context}}
{{form.extra_context.ptype}}
etc..
So what I ended up using on the template was:
which I had already tried.
The problem, and I’m still not sure why was that I had:
and what worked was:
For some reason, the ‘step’ that is being passed to ‘process_step()’ is always == 0 which made my ‘if step ==1:’ logic fail…
After reviewing the source (django.contrib.formtools.wizard.FormWizard), one thing that looks like it could be failing on is my form is not valid. It must be valid for the step number to increment and call the process_step function. HOWEVER, the {{step}} variable is getting the right value. And I’m not doing anything crazy with the form…
So weird. But my main question is solved.