Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

mikedrawback/djangorestframework-docjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocJSON tools for Django REST Framework

Some helper classes and functions for Django REST Framework for building hypermedia APIs in the DocJSON document format.

Fields

DocJSONIdentityField

Subclass of HyperlinkedIdentityField that wraps the hyperlink in {'_type': 'link': 'url': '...'}:

from rest_framework_docjson.fields import DocJSONIdentityField

class ArticleSerializer(serializers.ModelSerializer):
    permalink = DocJSONIdentityField(view_name='article-detail')

class Meta:
    model = Article

Functions

reverse

Same as Django Rest Framework's reverse() but wraps the returned URL in {'_type': 'link': 'url': '...'}.

Renderers

DocJSONRenderer and UnicodeDocJSONRenderer

Adds to top level element {"_type": "document} to the serialized data before rendering. Also uses the view's get_view_name() and get_view_description() to populate the "meta": "title" and "meta": "description".

media type: 'vnd.document+json' format: 'docjson'

In accordance with the IANA assignment here.

About

DocJSON tools for Django Rest Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages