Quantcast
Channel: How to make trailing slash optional in django - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Yarrow for How to make trailing slash optional in django

$
0
0

Not a direct answer to the question, but may save headache for someone with case similar to mine.

Trailing slash is optional by default because of APPEND_SLASH setting (if you include CommonMiddleware), and it makes Django redirect 'url' to 'url/' (if 'url' is not a valid url pattern itself).For some specific reasons I needed optional trailing slash without redirect, so I came to re_path(r'^url/?$', ...) option mentioned above, and it works. BUT - redirects from APPEND_SLASH are 301 Permanent, so for your new url config to start working without redirect, you need to turn on "Disable cache" in browser devtools Networking tab.


Viewing all articles
Browse latest Browse all 3


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>