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.