[Answered ]-Can Django infer a view name from the url?


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]


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.

Leave a comment