Skip to content
Advertisement

django 404 when loading admin but not local pages when deployed to heroku

I have just deployed my Django application to Heroku, All my locally saved apps load fine but not the django admin page

JavaScript

When I go to the home page it loads and the same for all other URLs, except for the admin page at https://myapp.herokuapp.com/admin and you get the following error. Hosted on Heroku: enter image description here Hosted on local machine: enter image description here

In heroku logs there is the following message (when going to /admin/)

JavaScript

Advertisement

Answer

If you want /admin to point to the admin you should turn on the APPEND_SLASH setting, otherwise you need to navigate to /admin/ (note the trailing slash).

APPEND_SLASH

When set to True, if the request URL does not match any of the patterns in the URLconf and it doesn’t end in a slash, an HTTP redirect is issued to the same URL with a slash appended.

You can see in the debug output that there is a URL pattern for admin/, but the requested path is admin (without the trailing slash) so it won’t match.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement