It seems by default django's url solver perform case sensitive search for solving url and differentiate between '/Login' and 'login'. My url patterns are as follows.
urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT, 'show_indexes': True}), (r'^login/$', 'django.contrib.auth.views.login'), (r'^logout/$', do_logout), )
Can anyone please guide me, how to make django urls case insensitive?
Just put (?i)
at the start of every r'...'
string, i.e.:
urlpatterns = patterns('', (r'^(?i)admin/(.*)', admin.site.root), (r'^(?i)static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT, 'show_indexes': True}), (r'^(?i)login/$', 'django.contrib.auth.views.login'), (r'^(?i)logout/$', do_logout), )
to tell every RE to match case-insensitively -- and, of course, live happily ever after!-)
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