[Django]-Django catch-all URL without breaking APPEND_SLASH

80👍

Make sure that your catch-all URL pattern has a slash at the end, and that the pattern is the last in your URLconf. If the catch-all pattern doesn’t end with a slash, then it will match stray URLs before the middleware tries appending a slash.

For example, use r'^.*/$' instead of r'^.*' as your last pattern.

To do the same, but pass the url to the view as a named argument, use r'^(?P<url>.*)/$'.

0👍

The statement if it finds an appropriate static page in the database seems like your static pages are not quite static so, you either pass your links through urls.py (just like you do now), or you extract those pages from the DB, put them in a directory and configure that directory as one for serving static files

Leave a comment