VarunVyas
VarunVyas

Reputation: 1445

Once custom 404 page comes for Django it doesn't redirect

I have created a custom 404 page for error on Django and it renders correctly(using render function in views). However, once this page appears, it doesn't go back to home page, even if explicit url is provided.

Upvotes: 0

Views: 84

Answers (1)

Cromulent
Cromulent

Reputation: 3818

An HTTP 404 response won't automatically redirect to another page. That is not the purpose of a 404 response. You'll need to use something like JavaScript to redirect to the home page after a certain time frame has passed. Do this by providing your own 404 template within Django (called 404.html in the top level of your templates tree).

Sounds like you really want an HTTP 301 or 302 response so that if a page is not found it will automatically redirect to the home page.

Upvotes: 1

Related Questions