Is this the proper way to assign a view method to multiple URLS?

51 Views Asked by At

I guess I should first of all ask if this is possible, and second am I doing this correctly? I am just trying to make userena_views.signup to a second url (test) and also assign a different template on the second one.

urlpatterns = patterns('',
    # Signup, signin and signout
    url(r'^signup/$',
       userena_views.signup,
       name='userena_signup'),
    url(r'^test/$',
      userena_views.signup, {'template_name': 'myproject/templates/custom.html',},
      name='userena_signup')
1

There are 1 best solutions below

0
awwester On

How I would go about that is to pass in a parameter. Inside the view you would assign the template based on which parameter was passed in. It is a little messy and better not to modify the site-package code, but sometimes it is necessary.

urlpatterns = patterns('',
    # Signup, signin and signout
    url(r'^(?P<signup_type>signup)/$', userena_views.signup, name='userena_signup'),
    url(r'^(?P<signup_type>test)/$', userena_views.signup, name='test_userena_signup')