Skip to content

Instantly share code, notes, and snippets.

@navyad navyad/responses.py
Created Aug 2, 2016

Embed
What would you like to do?
methods for API responses
from django.http.response import JsonResponse
def _send(data, status_code):
"""
Generic method to send the JSON response
"""
return JsonResponse(data=data, status=status_code)
def send_200(data):
return _send(data, 200)
def send_201(data):
return _send(data, 201)
def send_400(data):
return _send(data, 400)
def send_404(data):
return _send(data, 404)
def send_204(data):
return _send(data, 204)
def send_401(data):
return _send(data, 401)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.