django-rest-framework-json-api | JSON : API support for Django REST framework | REST library
kandi X-RAY | django-rest-framework-json-api Summary
kandi X-RAY | django-rest-framework-json-api Summary
JSON:API support for Django REST framework
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get the queryset for the serializer
- Returns a list of included resources
- Return a list of included resources
- Handles patch requests
- Format a link segment
- Instantiate a serializer instance
- Return the field name for the related field
- Returns the links to the object
- Resolve a hyperlink to a hyperlink
- Build a paginated response
- Validate internal value
- Default exception handler
- Validate and return internal value
- Returns a response object
- Convert to internal value
- Retrieve related models
- Get fields from queryset
- Gets the queryset
- Return the choices for the field
- Get package data
- Returns a dict of links to this resource
- Returns the filterset
- Return a list of all installed python packages
- Returns the polymorphic model for the given object type
- Parse the given stream
- Return a representation of the model
django-rest-framework-json-api Key Features
django-rest-framework-json-api Examples and Code Snippets
Community Discussions
Trending Discussions on django-rest-framework-json-api
QUESTION
Using django-rest-framework-json-api
I am able to create API end points that work as described within the documentation. Attempted to provide API documentation using django-rest-swagger
is not so easy.
1: Swagger uses media_type = 'application/json'
which is not supported in the JSON API. To get around this I created a second render class (renderer_classes
) that sub classes the JSON API JSONRenderer
and forces the media type.
Now the end point supports application/json
and application/vnd.api+json
and swagger is happy to render in JSON API document structure. Aware that the generated curl requests have none a standard JSON API header.
2: Swagger has the same issue with the parser. While the work out from issue 1 does work there is a secondary challenge. Swagger renders a flat dictionary of field names which is not JSON API and ultimately is requested by DRF.
Is it possible to get swagger to parse in JSON API? At the moment Swagger is not working for PUT or POST.
...ANSWER
Answered 2019-Apr-26 at 00:29Answering my own question here so that others can gain value from what was learnt. We never found a solution to this issue and we did not have the time available to contribute to this project. In general the project also appears to be struggling, maybe due to people like us not contributing...
An alternative project drf-yasg
has now emerged, which did not exist at the time of this original posting. drf-yasg
was relatively easy to deploy and solved all of our issues so we have now migrated to this project instead.
So if you a looking for swagger api documentation for JSON API endpoints created within DRF, then I would suggest drf-yasg
.
At the time of writing JSON API is not supported out of the box, but there is sample code to get it up and running relatively easily. With this change in place, all of the endpoints will be auto documented.
This Github Gist that contains the code from our app, hope that this helps you out until this feature is fully developed.
QUESTION
In our project we are using ResourceRelatedField for a foreign key field in one of our serializers to comply with JSON:API format. This is how it looks:
...ANSWER
Answered 2019-Nov-27 at 09:24Perhaps You can use a SerializerMethodResourceRelatedField? (not tested).
QUESTION
This is what I have so far.
My serializer:
...ANSWER
Answered 2019-Jan-07 at 21:56Ok, I am actually surprised that the creation of a single object instance works, since the data doesn't seem to be in the correct format.
When the many
argument is used, the serializer expects a list but what you send is a json object.
This is what the JSON should like:
QUESTION
I'm trying to create a JSON API compliant rest service using Django Rest Framework JSON API: https://django-rest-framework-json-api.readthedocs.io/en/stable/index.html
I think I'm stuck at the Django Rest Framework level, but I am not certain.
I think the GET request is working, but the POST is not because I get this response:
...ANSWER
Answered 2018-Sep-07 at 03:21Add some API prefix to your url include statement as,
QUESTION
I am trying to understand how polymorphic resources work in django-rest-framework-json-api and I get the following error both on my own project and the example project provided by django-rest-framework-json-api. My models are created using django-polymorphic. The example project I am trying to run is https://github.com/django-json-api/django-rest-framework-json-api/tree/master/example.
Endpoint : localhost:8000/projects
ANSWER
Answered 2018-May-08 at 21:38I was initially trying to create instances in the browser which threw the error above and didn't let me choose child types. I tested this on Postman and specified the type and it worked. I had the impression that I could even create an instance of Project as well (Parent instance itself, not a child instance) but as error message clearly says, I can't.
QUESTION
I am using Django 1.10 with DRF 3.5 and Django Rest Framework JSON API 2.1.1. I have a Viewset that follows the normal pattern of a ModelViewset, but I need to add an ad-hoc as follows:
...ANSWER
Answered 2017-Feb-14 at 07:37The ViewSet
is the controller of the resource. It doesn't make sense to set a method on a ViewSet
and associate it with another resource.
Either write a function with decorator to make an API entry point or get a new ViewSet
for it.
QUESTION
I am writing an HTTP API that uses django + django REST framework + django REST framework JSON API. When I tried to do PATCH request I received this error,
Incorrect type. Expected URL string, received OrderedDict
when updating relationship. Looking through issues I understood I need to use ResourceRelatedField.
I'm trying to follow documentation here Related fields. Below is how my code looks like.
urls.py
...ANSWER
Answered 2017-Feb-13 at 20:55Renaming event_pk
to pk
in url argument solved the problem.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-rest-framework-json-api
You can use django-rest-framework-json-api like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page