Tuesday, May 15, 2012


If you're coming from another CMS or Framework like me, then Django is probably messing up your weblinks too with the APPEND_SLASH option. (Since when is it more user friendly or beneficial to put a slash after every url? Most websites on the internet leave the end slash off, and Django seems to be going against common convention in this regard.)

You could leave APPEND_SLASH off, but this may lead to problems with SEO.

Anyway, I love Django in many other ways, and thankfully Django is flexible enough to allow us to fix this problem. I developed a middleware that basically does the opposite of APPEND_SLASH, and it's accordingly named Remove Slash Middleware.

It simply works like this:
1. Remove all slashes from the end of the requested url.
2. If the url location is not found, then add one slash '/' and try again.

Now you can choose to get rid of all those slashes at the ends of your urls. Delete, subtract, pop, erase those slashes.

Comment or leave feedback sepero 111 @ gmx . com

1 comment:

  1. Exactly. A slash isn't an end, it's a beginning (e.g. /etc). This is recognized everywhere on the planet except in the Django world. Very odd. I always strip them.