Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e552413

Browse files
authored
Deprecated support for django-polymorphic resources (#1303)
Desired for Django Polymorphic support to be added in an external 3rd party library in case there is a demand and someone is to be found who will take the lead.
1 parent 88721b9 commit e552413

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ any parts of the framework not mentioned in the documentation should generally b
1414

1515
* Ensured that an empty `included` array is returned in responses when the `include` query parameter is present but no related resources exist.
1616

17+
### Deprecated
18+
19+
* Deprecated support for using Polymorphic resources through [django-polymorphic](https://github.com/jazzband/django-polymorphic). There is currently no replacement. In case you are affected of this change please join [our discussion](https://github.com/django-json-api/django-rest-framework-json-api/discussions/1194).
20+
1721
## [8.0.0] - 2025年07月24日
1822

1923
### Added

‎docs/usage.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,17 @@ field_name_mapping = {
863863

864864
### Working with polymorphic resources
865865

866+
--
867+
868+
**Deprecation notice:**
869+
870+
871+
Support for using Polymorphic resources through [django-polymorphic](https://github.com/jazzband/django-polymorphic) is deprecated and will be removed in a future release.
872+
873+
There is currently no replacement. In case you are affected of this change please join [our discussion](https://github.com/django-json-api/django-rest-framework-json-api/discussions/1194).
874+
875+
---
876+
866877
Polymorphic resources allow you to use specialized subclasses without requiring
867878
special endpoints to expose the specialized versions. For example, if you had a
868879
`Project` that could be either an `ArtProject` or a `ResearchProject`, you can

‎rest_framework_json_api/serializers.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from collections.abc import Mapping
23

34
from django.core.exceptions import ObjectDoesNotExist
@@ -342,6 +343,16 @@ def __new__(cls, name, bases, attrs):
342343
if not parents:
343344
return new_class
344345

346+
warnings.warn(
347+
DeprecationWarning(
348+
"Support for polymorphic resources is deprecated."
349+
"There is currently no replacement. In case you are affected of this "
350+
"change please join discussion at "
351+
"https://github.com/django-json-api/django-rest-framework-json-api/discussions/1194."
352+
),
353+
stacklevel=2,
354+
)
355+
345356
polymorphic_serializers = getattr(new_class, "polymorphic_serializers", None)
346357
assert (
347358
polymorphic_serializers is not None

‎setup.cfg‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ DJANGO_SETTINGS_MODULE=example.settings.test
6363
filterwarnings =
6464
error::DeprecationWarning
6565
error::PendingDeprecationWarning
66+
ignore:Support for polymorphic resources is deprecated
6667
testpaths =
6768
example
6869
tests

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /