You need to define the Http header in order to have the status 404.
return HttpResponse(content=template.render(context), content_type='text/html; charset=utf-8', status=404)
It is important that search engines report that the current page is 404. Spammers sometimes create a lot of URLs that may seem to take you to some place, but then you will be presented with different content. They often make a lot of different addresses, and you get almost accurate content. And because it is not user friendly, most SEO search guides punish this. Therefore, if you have many addresses showing the same pseudo-404 content, this may not look good for crawling systems from search websites. Because of this, you want to make sure that the page that you use as a custom 404 has a status of 404.
If you are trying to create a custom 404 page, here is a good way:
In your urls.py application add:
# Imports from django.conf.urls.static import static from django.conf.urls import handler404 from django.conf.urls import patterns, include, url from yourapplication import views
In your views.py application add:
The secret is in the last line: status = 404
Hope this helps!
I look forward to the community contributing to this approach. =)
source share