我正在使用 Django 1.4。我花了很长时间在 django 页面上搜索和查看文档,https: //docs.djangoproject.com/en/1.4/ref/contrib/formtools/form-wizard/等。很少有人问过这个问题并且碰巧没有人回答它。
我需要做的是:
使用 urls.py 中的 slug 参数(如下所示):
FORMS=[...]
url(r'^url/(?P<slug>[\w-]+)/form/$', WizardWizard.as_view(FORMS)),
在views.py中(如下):
class WizardWizard(SessionWizardView):
template_name = "template.html"
extra_context = Model.objects.filter(slug=slug) # HERE!
def done(self, form_list, **kwargs):
...