JSON:API support for Django REST framework

Tests Read the docs PyPi Version

Overview

JSON:API support for Django REST framework

By default, Django REST framework will produce a response like:

{
    "count": 20,
    "next": "http://example.com/api/1.0/identities/?page=3",
    "previous": "http://example.com/api/1.0/identities/?page=1",
    "results": [{
        "id": 3,
        "username": "john",
        "full_name": "John Coltrane"
    }]
}

However, for an identity model in JSON:API format the response should look like the following:

{
    "links": {
        "prev": "http://example.com/api/1.0/identities",
        "self": "http://example.com/api/1.0/identities?page=2",
        "next": "http://example.com/api/1.0/identities?page=3",
    },
    "data": [{
        "type": "identities",
        "id": "3",
        "attributes": {
            "username": "john",
            "full-name": "John Coltrane"
        }
    }],
    "meta": {
        "pagination": {
          "count": 20
        }
    }
}

Goals

As a Django REST framework JSON:API (short DJA) we are

 

 

 

To finish reading, please visit source site