我有一个5步注册表单,其中第一步嵌入到主页中。因此,step1是主页的一部分,其余步骤将贯彻执行。我喜欢为step2到step5拥有唯一的URL。基于此我尝试设计URLS但我仍然坚持如何离开第一步成为主页URL(mysite.com),其余的就像mysite.com/signup/step2等。
以前曾是我的单一工作网址
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),
)
如何将step1作为主页URL和其余步骤的唯一URL?
答案 0 :(得分: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'),
)