Shashank's Blog

Skip to content
  • General
  • Programming Language
    • Python
  • Database
    • SQL
    • MySQL
    • Postgresql
  • Web Framework
    • Django
  • Linux/Unix
    • Linux Commands
Search

Http404

Django – AttributeError: ‘Http404’ object has no attribute ‘status_code’

March 17, 2015March 17, 2015 / Shashank vivek / 1 Comment

If you getting this error, it might be because you are returning Http404 instead of raising it.
you need to raise django.http.Http404, not return it.

example code :

from django.http import Http404

def my_view(request):
    try:
        my_object = MyModel.objects.get(pk=1)
    except MyModel.DoesNotExist:
        raise Http404

Translate

Recent Posts

  • Dump only Data in PostgreSQL table backup April 6, 2020
  • Number of rows per partition in a MySQL table November 4, 2019
  • What is GIPSA ? November 2, 2019
  • Difference between two dates in mysql July 20, 2018
  • Reading CSV file in python February 24, 2018

RSS Feed

  • RSS - Posts

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy