0

http://127.0.0.1:8000/app/slug/

With Debug=True I get Page not found (404) - No entry found matching the query. With Debug=False I get shown the projectName/templates/500.html instead of 404.html.

Both look exactly the same. 500.html:

{% extends "base.html" %}

{% block title %}server error{% endblock %}

{% block content %}

<h3>Error 500: server error</h3>

{% endblock %}

404.html:

{% extends "base.html" %}

{% block title %}page not found{% endblock %}

{% block content %}

<h3>Error 404: page not found</h3>

{% endblock %}

Why does Django load 500 instead of 404 although it exists? It cannot be a template error.

orschiro
  • 19,847
  • 19
  • 64
  • 95
  • 5
    what's your django version?,if you use django1.5 and Debug=False,you must add `ALLOWED_HOSTS` in `settings` more details:https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS – liuzhijun Jul 29 '13 at 10:35
  • Yes, I am using django 1.5. I tried `ALLOWED_HOSTS = ['http://127.0.0.1:8000/', 'localhost']` but it still raises the 500 error when trying it locally. – orschiro Jul 29 '13 at 11:26
  • I figured it out. This one works: `ALLOWED_HOSTS = ['localhost', '127.0.0.1']` – orschiro Jul 29 '13 at 12:23

1 Answers1

0

If you're 100% sure that you've correctly set up ALLOWED_HOSTS in your settings, chances are your 404.html template is somehow not correct. There might be a syntax error (or it can't find the base template), which, in turn, causes a new 500 exception to be raised.

Try simplifying your 404.html by only including static HTML.

Ricky
  • 1
  • 1
  • 2