Reputation: 2217
I have the following urls
url(r'^signup/','social.views.signup'),
url(r'^submit_signup/','social.views.submit_signup'),
url(r'^signup_complete/','social.views.signup_complete'),
Could I make a url that would choose the view based on the url? Like:
url(r'*/', 'social.views.*')
so that a request to /signup would route to 'social.views.signup'
Upvotes: 1
Views: 114
Reputation: 2086
If you want to make signup process of multiple steps than you can user Django form wizard. In this way you don't need to change url for every signup step. The URL will look like this:
url(r'^signup/$', SignupWizard([SignupForm_1, SignupForm_2, SignupFormComplete]) ),
Check the form wizard documentation.
Upvotes: 0
Reputation: 1215
somehow like this
def test(*args,**kwargs):
view_name = kwargs.pop('view')
view = getattr(social.views,view_name)
return view(*args, **kwargs)
urlpatterns = patterns('',
url(r'^test/(?P<view>.*)$', test),
...
)
or like this
VIEWS_LIST = ['signup','submit_signup','signup_complete']
urlpatterns = patterns('social.views',
*[url('%s/' % view,view) for view in VIEWS_LIST]
)
Upvotes: 2