I have a Django 1.9 application, When the DEBUG
is true
. The application redirects to url with a trailing slash if it was not present. But I am getting a 404 error when the DEBUG
is False
. I tried adding setting APPEND_SLASH = True
, but nothing changed. My setup is nginx + gunicorn + Django 1.9.
Any insights are appreciated. Thank you.
Slash appending was moved to response handler in Django 1.9 and is only applied if the response.status_code
is 404: https://github.com/django/django/blob/1.9.3/django/middleware/common.py#L113
I've encountered same issue issue and in my case this was caused by my custom 404 view that actually returned HTTP 200. Make sure your 404 view creates responses with 404 status_code.
The reason this behavior doesn't happen with DEBUG = True
is that custom 404 is not used when in DEBUG
mode.