Django 404 page not showing up

2019-08-13 08:37发布

问题:

I'm in the middle of putting up my first django application on shared hosting. This should be an easy thing, but I am just not seeing it.

I tried to follow the directions of the django documentation, and created a 404.html page within my template folder. I just wrote "This is a 404 page." in the .html file. I also did the same thing for a 500.html page and wrote in it "This is a 500 page."

However when I hit a 'bad page' I get a standard 404 page from the browser (Oops! This link appears to be broken. in Chrome) when I would expect "This is a 404 page."

What's even more interesting is out of frustration I wrote {% asdfjasdf %} in the 404.html, and instead of getting the "Oops!..." error I get "This is a 500 page," so it definitely sees the 404.html template.

Here's what I can confirm:

  • Debug = False
  • I am running apache on a shared hosting
  • I have not done anything special with .htaccess and 404 errors.
  • If I run with Debug = True, it says it's a 404 error.
  • I am using FastCGI

Anything else anyone think I could try?

Thank you very much!

回答1:

See this related question: Django 404 pages not appearing?

I don't think this has to do with your setup. Chrome is hijacking the 404 page and showing the 'Oops' message. I would expect that if you tried to view the 404 page in another browser you would see it as expected.