All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Note that in line with Django REST framework policy, any parts of the framework not mentioned in the documentation should generally be considered private API, and may be subject to change.
- Handled zero as a valid ID for resource (regression since 6.1.0)
- Ensured that patching a To-Many relationship with the
RelationshipView
correctly raises request error when passing inNone
. For emptying a To-Many relationship an empty array should be used as per JSON:API spec
- Added support for Django 5.1
- Added support for Python 3.13
- Deprecated built-in support for generating OpenAPI schema. Use drf-spectacular-json-api instead.
- Allow overwriting of url field again (regression since 7.0.0)
- Ensured that no fields are rendered when sparse fields is set to an empty value. (regression since 7.0.0)
- Added
429 Too Many Requests
as a possible error response in the OpenAPI schema.
- Ensured that URL and id field are kept when using sparse fields (regression since 7.0.0)
- Added support for Python 3.12
- Added support for Django 5.0
- Added support for Django REST framework 3.15
- Fixed OpenAPI schema generation for
Serializer
when used inside anotherSerializer
or as a child ofListField
. ModelSerializer
fields are now returned in the same order than DRF- Avoided that an empty attributes dict is rendered in case serializer does not provide any attribute fields.
- Avoided shadowing of exception when rendering errors (regression since 4.3.0).
- Ensured that sparse fields only applies when rendering, not when parsing.
- Adjusted that sparse fields properly removes meta fields when not defined.
- Removed support for Python 3.7.
- Removed support for Django 3.2.
- Removed support for Django 4.0.
- Removed support for Django 4.1.
- Removed support for Django REST framework 3.13.
- Removed obsolete compat
NullBooleanField
andget_reference
definitions.
This is the last release supporting Python 3.7, Django 3.2, Django 4.0, Django 4.1 and Django REST framework 3.13.
- Added support for Python 3.11.
- Added support for Django 4.2.
- Added
400 Bad Request
as a possible error response in the OpenAPI schema.
-
Added support to overwrite serializer methods in customized schema class
-
Adjusted some still old formatted strings to f-strings.
-
Replaced
OrderedDict
withdict
which is also ordered since Python 3.7. -
Compound document "include" parameter is only included in the OpenAPI schema if serializer implements
included_serializers
. -
Allowed overwriting of resource id by defining an
id
field on the serializer.Example:
class CustomIdSerializer(serializers.Serializer): id = serializers.CharField(source='name') body = serializers.CharField()
-
Allowed overwriting resource id on resource related fields by creating custom
ResourceRelatedField
.Example:
class CustomResourceRelatedField(relations.ResourceRelatedField): def get_resource_id(self, value): return value.name
-
SerializerMethodResourceRelatedField(many=True)
relationship data now includes a meta section. -
Required relationship fields are now marked as required in the OpenAPI schema.
-
Objects in the included array are documented in the OpenAPI schema to possibly have additional properties in their "attributes" and "relationships" objects.
- Refactored handling of the
sort
query parameter to fix duplicate declaration in the generated OpenAPI schema definition - Non-field serializer errors are given a source.pointer value of "/data".
- Fixed "id" field being added to /data/attributes in the OpenAPI schema when it is not rendered there.
- Fixed
SerializerMethodResourceRelatedField(many=True)
fields being given a "reltoone" schema reference instead of "reltomany". - Callable field default values are excluded from the OpenAPI schema, as they don't resolve to YAML data types.
- Fixed invalid relationship pointer in error objects when field naming formatting is used.
- Properly resolved related resource type when nested source field is defined.
- Prevented overwriting of pointer in custom error object
- Adhered to field naming format setting when generating schema parameters and required fields.
- Added support for Django 4.1.
- Added support for Django REST framework 3.14.
- Expanded JSONParser API with
parse_data
method
- Improved documentation of how to override DRF's generateschema
--generator_class
to generate a proper DJA OAS schema.
- Removed support for Django 2.2.
- Removed support for Django REST framework 3.12.
This release is not backwards compatible. For easy migration best upgrade first to version 4.3.0 and resolve all deprecation warnings before updating to 5.0.0
This is the last release supporting Django 2.2 and Django REST framework 3.12.
- Added support for Django REST framework 3.13.
- Adjusted to only use f-strings for slight performance improvement.
- Set minimum required version of inflection to 0.5.
- Set minimum required version of Django Filter to 2.4.
- Set minimum required version of Polymorphic Models for Django to 3.0.
- Set minimum required version of PyYAML to 5.4.
- Removed support for Django 3.0.
- Removed support for Django 3.1.
- Removed support for Python 3.6.
- Removed obsolete method
utils.get_included_serializers
. - Removed optional
format_type
argument ofutils.format_link_segment
. - Removed
format_type
s default argument ofutils.format_value
.format_type
is now required.
This is the last release supporting Django 3.0, Django 3.1 and Python 3.6.
- Added support for Django 4.0.
- Added support for Python 3.10.
- Adjusted error messages to correctly use capital "JSON:API" abbreviation as used in the specification.
- Avoid error when
parser_context
isNone
while parsing. - Raise comprehensible error when reserved field names
meta
andresults
are used. - Use
relationships
in the error objectpointer
when the field is actually a relationship. - Added missing inflection to the generated OpenAPI schema.
- Added missing error message when
resource_name
is not properly configured.
- Moved resolving of
included_serialzers
andrelated_serializers
classes to serializer's meta class.
- Deprecated
get_included_serializers(serializer)
function underrest_framework_json_api.utils
. Useserializer.included_serializers
instead. - Deprecated support for field name
type
as it may not be used according to the JSON:API spec.
- Included
PreloadIncludesMixin
inReadOnlyModelViewSet
to enable the usage of performance utilities on read only views (regression since 2.8.0) - Removed invalid validation of default
included_resources
(regression since 4.2.0)
- Added support for Django 3.2.
- Added support for tags in OAS schema
- Allow
get_serializer_class
to be overwritten when using related urls without definingserializer_class
fallback - Preserve field names when no formatting is configured.
- Properly support
JSON_API_FORMAT_RELATED_LINKS
setting in related urls. In case you want to usedasherize
for formatting links make sure that your url pattern matches dashes as well like following example:url(r'^orders/(?P<pk>[^/.]+)/(?P<related_field>[-\w]+)/$', OrderViewSet.as_view({'get': 'retrieve_related'}), name='order-related'),
- Ensure default
included_resources
are considered when calculating prefetches. - Avoided error when using
include
query parameter on related urls (a regression since 4.1.0)
- Deprecated default
format_type
argument ofrest_framework_json_api.utils.format_value
. Userest_framework_json_api.utils.format_field_name
or specify specifcformat_type
instead. - Deprecated
format_type
argument ofrest_framework_json_api.utils.format_link_segment
. Userest_framework_json_api.utils.format_value
instead.
- Ability for the user to select
included_serializers
to apply when usingBrowsableAPI
, based on availableincluded_serializers
defined for the current endpoint. - Ability for the user to format serializer properties in URL segments using the
JSON_API_FORMAT_RELATED_LINKS
setting.
- Allow users to overwrite a view's
get_serializer_class()
method when using related urls - Correctly resolve the resource type of
ResourceRelatedField(many=True)
fields on plain serializers - Render
meta_fields
in included resources
This release is not backwards compatible. For easy migration best upgrade first to version 3.2.0 and resolve all deprecation warnings before updating to 4.0.0
- Added support for Django REST framework 3.12.
- Added support for Django 3.1.
- Added support for Python 3.9.
- Added initial optional support for openapi schema generation. Enable with:
This first release is a start at implementing OAS schema generation. To use the generated schema you may still need to manually add some schema attributes but can expect future improvements here and as upstream DRF's OAS schema generation continues to mature.
pip install djangorestframework-jsonapi['openapi']
- Removed support for Python 3.5.
- Removed support for Django 1.11.
- Removed support for Django 2.1.
- Removed support for Django REST framework 3.10 and 3.11.
- Removed obsolete
source
argument ofSerializerMethodResourceRelatedField
. - Removed obsolete setting
JSON_API_SERIALIZE_NESTED_SERIALIZERS_AS_ATTRIBUTE
to render nested serializers as relationships. Default is render as attribute now.
- Stopped
SparseFieldsetsMixin
interpretting invalid fields query parameter (e.g. invalidfields[entries]=blog,headline).
This is the last release supporting Django 1.11, Django 2.1, Django REST framework 3.10, Django REST framework 3.11 and Python 3.5.
- Added support for serializing nested serializers as attribute json value introducing setting
JSON_API_SERIALIZE_NESTED_SERIALIZERS_AS_ATTRIBUTE
- Note: As keys of nested serializers are not JSON:API spec field names they are not inflected by format field names option.
- Added
rest_framework_json_api.serializer.Serializer
class to support initial JSON:API views without models.- Note that serializers derived from this class need to define
resource_name
in theirMeta
class. - This fix might be a BREAKING CHANGE if you use
rest_framework_json_api.serializers.Serializer
for non JSON:API spec views (usuallyAPIView
). You need to change those serializers classes to userest_framework.serializers.Serializer
instead.
- Note that serializers derived from this class need to define
- Avoid
AttributeError
for PUT and PATCH methods when usingAPIView
- Clear many-to-many relationships instead of deleting related objects during PATCH on
RelationshipView
- Allow POST, PATCH, DELETE for actions in
ReadOnlyModelViewSet
. Regression since version2.8.0
. - Properly format nested errors
SerializerMethodResourceRelatedField
is now consistent with DRFSerializerMethodField
:- Pass
method_name
argument to specify method name. If no value is provided, it defaults toget_{field_name}
- Pass
- Allowed repeated filter query parameters.
- Deprecate
source
argument ofSerializerMethodResourceRelatedField
, usemethod_name
instead - Rendering nested serializers as relationships is deprecated. Use
ResourceRelatedField
instead
- Added support for Python 3.8
- Added support for Django REST framework 3.11
- Added support for Django 3.0
- Ensured that
409 Conflict
is returned when processing aPATCH
request in which the resource object’s type and id do not match the server’s endpoint as outlined in JSON:API spec. - Properly return parser error when primary data is of invalid type
- Pass instance to child serializers when using
PolymorphicModelSerializer
- Properly resolve related resource type when using
PolymorphicModelSerializer
This release is not backwards compatible. For easy migration best upgrade first to version 2.8.0 and resolve all deprecation warnings before updating to 3.0.0
- Added support for Django REST framework 3.10.
- Added code from
ErrorDetail
into the JSON:API error object.
- Moved dependency definition for
django-polymorphic
anddjango-filter
into extra requires. Hence dependencies of each optional module can be installed with pip usingpip install djangorestframework-jsonapi['django-polymorphic'] pip install djangorestframework-jsonapi['django-filter']
- Removed support for Python 2.7 and 3.4.
- Removed support for Django Filter 1.1.
- Removed obsolete dependency six.
- Removed support for Django REST framework <=3.9.
- Removed support for Django 2.0.
- Removed obsolete mixins
MultipleIDMixin
andPrefetchForIncludesHelperMixin
- Removed obsolete settings
JSON_API_FORMAT_KEYS
,JSON_API_FORMAT_RELATION_KEYS
andJSON_API_PLURALIZE_RELATION_TYPE
- Removed obsolete util methods
format_keys
andformat_relation_name
- Removed obsolete pagination classes
PageNumberPagination
andLimitOffsetPagination
- Avoid printing invalid pointer when api returns 404.
- Avoid exception when using
ResourceIdentifierObjectSerializer
with unexisting primary key. - Format metadata field names correctly for OPTIONS request.
This is the last release supporting Python 2.7, Python 3.4, Django Filter 1.1, Django REST framework <=3.9 and Django 2.0.
- Add support for Django 2.2
- Allow to define
select_related
per include using select_for_includes - Use REST framework serializer functionality to extract includes. This adds support like using
dotted notations in source attribute in
ResourceRelatedField
.
- Avoid exception when trying to include skipped relationship
- Don't swallow
filter[]
params when there are several - Fix DeprecationWarning regarding collections.abc import in Python 3.7
- Allow OPTIONS request to be used on RelationshipView
- Remove non-JSON:API methods (PUT and TRACE) from ModelViewSet and RelationshipView. This fix might be a BREAKING CHANGE if your clients are incorrectly using PUT instead of PATCH.
- Avoid validation error for missing fields on a PATCH request using polymorphic serializers
- Deprecate
PrefetchForIncludesHelperMixin
usePreloadIncludesMixin
instead
- Add support for Django 2.1, DRF 3.9 and Python 3.7. Please note:
- Django >= 2.1 is not supported with Python < 3.5.
- Pass context from
PolymorphicModelSerializer
to child serializers to support fields which require arequest
context such asurl
. - Avoid patch on
RelationshipView
deleting relationship instance when constraint would allow null (#242) - Avoid error with related urls when retrieving relationship which is referenced as
ForeignKey
on parent - Do not render
write_only
relations - Do not skip empty one-to-one relationships
- Allow
HyperlinkRelatedField
to be used with related urls - Avoid exception in
AutoPrefetchMixin
when including a reverse one to one relation (#537) - Avoid requested resource(s) to be added to included as well (#524)
- Add testing configuration to
REST_FRAMEWORK
configuration as described in DRF - Add
HyperlinkedRelatedField
andSerializerMethodHyperlinkedRelatedField
. See usage docs - Add related urls support. See usage docs
- Add optional jsonapi-style filter backends. See usage docs
- Deprecate
MultipleIDMixin
because it doesn't comply with the JSON:API 1.0 spec. Replace it withDjangoFilterBackend
and change clients to usefilter[id.in]
query parameter instead ofids[]
. See usage docs. You also have the option to copy the mixin into your code.
- Replaced binary
drf_example
sqlite3 db with a fixture. See getting started. - Replaced unmaintained API doc with auto-generated API reference.
- Performance improvement when rendering relationships with
ModelSerializer
- Do not show deprecation warning when user has implemented custom pagination class overwriting default values.
- Add new pagination classes based on JSON:API query parameter recommendations:
JsonApiPageNumberPagination
andJsonApiLimitOffsetPagination
. See usage docs.
- Add
ReadOnlyModelViewSet
extension with prefetch mixins - Add support for Django REST framework 3.8.x
- Introduce
JSON_API_FORMAT_FIELD_NAMES
option replacingJSON_API_FORMAT_KEYS
but in comparison preserving values from being formatted as attributes can contain any json value. - Allow overwriting of
get_queryset()
in customResourceRelatedField
- Deprecate
PageNumberPagination
andLimitOffsetPagination
. UseJsonApiPageNumberPagination
andJsonApiLimitOffsetPagination
instead.- To retain deprecated values for
PageNumberPagination
andLimitOffsetPagination
create new custom class like the following in your code base:
and adjustclass CustomPageNumberPagination(PageNumberPagination): page_query_param = "page" page_size_query_param = "page_size" class CustomLimitOffsetPagination(LimitOffsetPagination): max_limit = None
REST_FRAMEWORK['DEFAULT_PAGINATION_CLASS']
setting accordingly. - To retain deprecated values for
- Deprecate
JSON_API_FORMAT_KEYS
, useJSON_API_FORMAT_FIELD_NAMES
.
- Performance improvement when rendering included data
- Add support for Django REST framework 3.7.x.
- Add support for Django 2.0.
- Drop support for Django 1.8 - 1.10 (EOL)
- Drop support for Django REST framework < 3.6.3 (3.6.3 is the first to support Django 1.11)
- Drop support for Python 3.3 (EOL)
- Add support for polymorphic models
- Add nested included serializer support for remapped relations
- Enforcing flake8 linting
- When
JSON_API_FORMAT_KEYS
is False (the default) do not translate request attributes and relations to snake_case format. This conversion was unexpected and there was no way to turn it off. - Fix for apps that don't use
django.contrib.contenttypes
. - Fix
resource_name
support for POST requests and nested serializers
- Add support for Django REST framework 3.5 and 3.6
- Add support for Django 1.11
- Add support for Python 3.6
- Allow default DRF serializers to operate even when mixed with DRF-JA serializers
- Avoid setting
id
toNone
in the parser simply because it's missing - Fix out of scope
relation_instance
variable in renderer - Fix wrong resource type for reverse foreign keys
- Fix documentation typos
- Parse
meta
in JSONParser - Add code coverage reporting and updated Django versions tested against
- Add support for regular non-ModelSerializers
- Documented built in
url
field for generating aself
link in thelinks
key - Convert
include
field names back to snake_case - Raise a
ParseError
if anid
is not included in a PATCH request
- Fix Django 1.10 compatibility
- Performance enhancements to reduce the number of queries in related payloads
- Fix issue where related
SerializerMethodRelatedField
fields were not included even if ininclude
- Fix bug that prevented
fields = ()
in a serializer from being valid - Fix stale data returned in PATCH to-one relation
- Fixes naming error that caused ModelSerializer relationships to fail
- Add
get_related_field_name
for views subclassing RelationshipView to override - Added LimitOffsetPagination
- Support deeply nested
?includes=foo.bar.baz
without returning intermediate models (bar) - Allow a view's serializer_class to be fetched at runtime via
get_serializer_class
- Added support for
get_root_meta
on list serializers
- Exception handler can now easily be used on DRF-JA views alongside regular DRF views
- Rename
JSON_API_FORMAT_RELATION_KEYS
toJSON_API_FORMAT_TYPES
to match what it was actually doing - Rename
JSON_API_PLURALIZE_RELATION_TYPE
toJSON_API_PLURALIZE_TYPES
- Documented ResourceRelatedField and RelationshipView
- Fixes bug where write_only fields still had their keys rendered