Skip to content

deprecate MultipleIDMixin #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ any parts of the framework not mentioned in the documentation should generally b
* Add related urls support. See [usage docs](docs/usage.md#related-urls)
* Add optional [jsonapi-style](http://jsonapi.org/format/) filter backends. See [usage docs](docs/usage.md#filter-backends)

### Deprecated

* Deprecate `MultipleIDMixin` because it doesn't comply with the JSON:API 1.0 spec. Replace it with
`DjangoFilterBackend` and **change clients** to use `filter[id.in]` query parameter instead of `ids[]`.
See [usage docs](docs/usage.md#djangofilterbackend).

### Changed

* Replaced binary `drf_example` sqlite3 db with a [fixture](example/fixtures/drf_example.json). See [getting started](docs/getting-started.md#running-the-example-app).
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,6 @@ override ``settings.REST_FRAMEWORK``
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
}

This package provides much more including automatic inflection of JSON keys, extra top level data (using nested serializers), relationships, links, and handy shortcuts like MultipleIDMixin. Read more at http://django-rest-framework-json-api.readthedocs.org/
This package provides much more including automatic inflection of JSON keys, extra top level data (using nested
serializers), relationships, links, paginators, filters, and handy shortcuts.
Read more at http://django-rest-framework-json-api.readthedocs.org/
16 changes: 16 additions & 0 deletions rest_framework_json_api/mixins.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
"""
Class Mixins.
"""
import warnings


class MultipleIDMixin(object):
"""
Override get_queryset for multiple id support

.. warning::

MultipleIDMixin is deprecated because it does not comply with http://jsonapi.org/format.
Instead add :py:class:`django_filters.DjangoFilterBackend` to your
list of `filter_backends` and change client usage from:
``?ids[]=id1,id2,...,idN`` to ``'?filter[id.in]=id1,id2,...,idN``

"""
def __init__(self, *args, **kwargs):
warnings.warn("MultipleIDMixin is deprecated. "
"Instead add django_filters.DjangoFilterBackend to your "
"list of 'filter_backends' and change client usage from: "
"'?ids[]=id1,id2,...,idN' to '?filter[id.in]=id1,id2,...,idN'",
DeprecationWarning)
super(MultipleIDMixin, self).__init__(*args, **kwargs)

def get_queryset(self):
"""
Expand Down