Skip to main content

Ready Jsend specified response classes.

Project description

Django Jsend Responses

Jsend specified Responses for APIs.


Overview

Django Jsend Responses supply response classes to use in projects created with Django. See http://labs.omniti.com/labs/jsend for jsend spec.


Requirements

  • Django (1.11, 2.0, 2.1)

Installation

Install using pip...

pip install djangojsendresponses

Using in a code

from jsend_responses import SuccessResponse
from rest_framework.views import APIView


class DriverAPIView(APIView):
    def get(self):
        driver = get_random_driver()
        return SuccessResponse(object=driver)

Response examples

Success response:

{
    "status": "success",
    "data": {
        "object": { 
            "id": 1, 
            "name": "Fist object"
        }
    }
}

Fail response:

{
    "status" : "fail",
    "data" : {
        "name" : "A name is required" 
    }
}

Error response:

{
    "status" : "error",
    "message" : "A service is unavailable to connect"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangojsendresponses-0.1.1.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

djangojsendresponses-0.1.1-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page