loading...

HTTP status codes and Django

isikkaplan profile image Işık Kaplan ・1 min read

I'm here to let you in on a little library I have that I've written to keep my django projects up to web standards, and sending the proper HTTP response codes. Say hi to django-http-exceptions.

That sounded like I've just written that, it is actually a year old and it's been just sitting there waiting for me to come up with new features. I'll quote the README of the repo so you can see what it does, and hopefully we can brainstorm some new ideas for possible new features.

It translates this

def some_function():
    raise SomeError

def view(request):
   try:
       response = some_function()
   except SomeError:
       response = HttpResponse(status=403)
   return response

into

def some_function():
    raise HTTPExceptions.FORBIDDEN

def view(request):
    return some_function() 

This is the most basic functionality. Check the project for more! Also, with the hacktoberfest being on the door, feel free to open issues for new features and send a pr or two.

Discussion

pic
Editor guide