Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append Slash not working

I have this urlConf and its working fine while accessing with a trailing slash.:

urlpatterns = patterns('', url(r'^allvideo/$','my.views.allvideo'))

Even though

APPEND_SLASH=True

it gives me attribute error "'str' object has no attribute 'resolve'", when request is made with missing trailing slash

Any idea??

like image 659
user1170364 Avatar asked Feb 27 '12 10:02

user1170364


1 Answers

APPEND_SLASH doesn't happen unconditionally -- it only comes into effect if, after trying all existing URL patterns (and the associated view, if one matches), Django is about to return a 404.

If that's the case, and the original request didn't have a slash at the end, then Django checks to see whether any URL patterns would match with a trailing slash. If so, it issues an HTTP redirect.

If any of your URL patterns match the original request (without the slash), then Django will try that one first. If that raises an exception, then you will see it (I suspect that this is what is happening). Django won't ever get to issue the redirect.

like image 54
Ian Clelland Avatar answered Sep 19 '22 13:09

Ian Clelland