编辑:FWIW,我正在运行
django 1.3
我有…
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))
我想将self.extra_context放到模板中.
我如何在模板上获得它?
我试过模板:
{{extra_context}}
{{form.extra_context}}
{{form.extra_context.ptype}}
等等..
最佳答案 看看
docs我会说
get_context_data
就是你所追求的:
Returns the template context for a step. You can overwrite this method
to add more data for all or some steps. This method returns a
dictionary containing the rendered form step.