afternero.blogg.se

Streamcloud 404 error
Streamcloud 404 error









streamcloud 404 error

DoesNotExist : raise Http404 ( "Post not found" ) return render ( request, 'blog/post_detail.html', return render ( request, 'blog/post_by_tag.html', context )įrom now on, all the pages of our blog will display posts in reverse chronological order. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. # view function to display a single post def post_detail ( request, pk ): try : post = Post. To see how it works, open views.py and modify the post_detail() view as follows:įrom django.http import HttpResponse, HttpResponseNotFound, Http404 #.

streamcloud 404 error

It works just like HttpResponse but instead of returning a 200 status code, it returns 404 (which means page not found).

streamcloud 404 error

The HttpResponseNotFound class is an extension of HttpResponse class. Let's start with HttpResponseNotFound class. Showing an HTTP 404 page #ĭjango provides two ways to show 404 error. Visit any tag or post detail page which doesn't exist like or and see it yourself. The same problem exists in the tag page and the post detail page. In production (i.e when DEBUG=True), instead of throwing a DoesNotExist exception Django will show 500 Internal Server Error.įrom the point of view of Search Engine Optimization (SEO), it would be much better to show an HTTP 404 error for the non-existent page instead of showing Internal Server Error or DoesNotExist exception. You should see DoesNotExist exception like this:Īs there is no such category in the database the URL is completely invalid. Visit a category page which doesn't exist for example.











Streamcloud 404 error