Is it possible to define multiple names for the one URL pattern? I'd like to merge two views without finding all the references to each and changing them. Another benefit in keeping both names is in case I ever want to split them again later.
For example, merging
url(r'^login/', TemplateView.as_view(template_name='login.html'), name='login'),
url(r'^profile/', TemplateView.as_view(template_name='profile.html'), name='profile'),
to
url(r'^profile/', TemplateView.as_view(template_name='profile.html'), name=('login', 'profile')), #???
No, it isn't possible to use a tuple for the url pattern's name. Just include the url pattern twice, with a different name each time.
url(r'^profile/$', TemplateView.as_view(template_name='profile.html'), name='login'),
url(r'^profile/$', TemplateView.as_view(template_name='profile.html'), name='profile'),
Note that I have terminated the regexes with a dollar. Without it, the regex will match /profile/sonething-else/
as well as /profile/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With