我正在使用Django 1.4。我花了很長一段時間的谷歌,並在django頁面上看文檔,https://docs.djangoproject.com/en/1.4/ref/contrib/formtools/form-wizard/等。很少有人問過這個問題,沒有人碰巧已經回答了這個問題。如何在Django中使用formwizard訪問URL參數並使用它們?
我需要做的是:在views.py
FORMS=[...]
url(r'^url/(?P<slug>[\w-]+)/form/$', WizardWizard.as_view(FORMS)),
(如下):
使用slug paramater從urls.py(如下)
class WizardWizard(SessionWizardView):
template_name = "template.html"
extra_context = Model.objects.filter(slug=slug) # HERE!
def done(self, form_list, **kwargs):
...
我發現這個:http://stackoverflow.com/questions/1947040/django-formwizard-and-view。但它不適用於我:( –