2

我有一个 5 步注册表单,其中第一步嵌入到主页中。所以第 1 步是主页的一部分,其余步骤将继续执行。我喜欢为第 2 步到第 5 步设置唯一的 URL。基于此,我尝试设计 URLS,但我被困在如何将第一步保留为主页 URL(mysite.com),其余部分类似于 mysite.com/signup/step2 等。

这曾经是我以前的单个工作 URL

from apps.profile.views.login import SignupWizard, SIGNUP_FORMS
    from apps.profile.forms import MultiPartSignupFormStep1, MultiPartSignupFormStep2, MultiPartSignupFormStep3, MultiPartSignupFormStep4,MultiPartSignupFormStep5

urlpatterns = patterns('apps.profile.views.login',
        url(r'^$', SignupWizard.as_view(SIGNUP_FORMS), name="signup"),
)

这是我现在的代码

from apps.profile.views.login import SignupWizard, SIGNUP_FORMS
from apps.profile.forms import MultiPartSignupFormStep1, MultiPartSignupFormStep2, MultiPartSignupFormStep3, MultiPartSignupFormStep4,MultiPartSignupFormStep5
named_forms = (
    ('step1', MultiPartSignupFormStep1),
    ('step2', MultiPartSignupFormStep2),
    ('step3', MultiPartSignupFormStep3),
    ('step4', MultiPartSignupFormStep4),
    ('step5', MultiPartSignupFormStep5),
)

wizard = SignupWizard.as_view(named_forms)
    #url_name='step1', done_step_name='finished')

urlpatterns = patterns('apps.profile.views.login',
    url(r'^account/signup/(?P<step>.+)/$', wizard),
    #url(r'^account/signup/$', wizard),

)

如何将第 1 步作为主页 URL 并为其余步骤设置唯一 URL?

4

1 回答 1

0

也许这会起作用:

from apps.profile.views.login import SignupWizard, SIGNUP_FORMS
from apps.profile.forms import MultiPartSignupFormStep1, MultiPartSignupFormStep2, MultiPartSignupFormStep3, MultiPartSignupFormStep4,MultiPartSignupFormStep5

step1 = (('step1', MultiPartSignupFormStep1),)
other_steps = (
    ('step2', MultiPartSignupFormStep2),
    ('step3', MultiPartSignupFormStep3),
    ('step4', MultiPartSignupFormStep4),
    ('step5', MultiPartSignupFormStep5),
)

wizard_step1 = SignupWizard.as_view(step1, url_name='wizard_step1')
wizard_other_steps = SignupWizard.as_view(other_steps, url_name='wizard_other_steps')

urlpatterns = patterns('apps.profile.views.login',
    url(r'^$', wizard_step1, name='wizard_step1'),
    url(r'^account/signup/(?P<step>.+)/$', wizard_other_steps, name='wizard_other_steps'),
)
于 2013-07-30T22:47:02.093 回答