Skip to content

Extract type for each related instance #94

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

Conversation

martinmaillard
Copy link
Contributor

Instead of extracting the resource type for the whole related collection, extract the type for each instance individually. This way, polymorphic relationships (using something like django_polymorphic) are
supported.

This PR addresses an issue raised in #77

The next step will be to allow customizing the way the type is extracted for each instance, but I'm not sure how to go about that...

Instead of extracting the resource type for the whole related
collection, extract the type for each instance individually. This way,
polymorphic relationships (using something like django_polymorphic) are
supported.
@jsenecal
Copy link
Member

Could you provide us with a way to replicate your issue and test your solution uppon it? I don't see any problem about it but I would like to make sure.

Also, what/how exactly does that address #77 ?

@martinmaillard
Copy link
Contributor Author

It addresses this comment #77 (comment)

I'll try to write a test.

@jsenecal
Copy link
Member

ha! okay I missed that comment - I have nothing against merging that... @jerel any objections ?

@jerel
Copy link
Member

jerel commented Sep 17, 2015

Once we get the example app set up properly we can require tests an a PR

jerel added a commit that referenced this pull request Sep 17, 2015
@jerel jerel merged commit 36b3a1b into django-json-api:develop Sep 17, 2015
@jsenecal jsenecal modified the milestone: 2.0 release Sep 30, 2015
@martinmaillard
Copy link
Contributor Author

Was that reverted ?

@jerel
Copy link
Member

jerel commented Oct 9, 2015

I don't believe so:
https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/utils.py#L370
On Oct 9, 2015 7:35 AM, "Martin Maillard" [email protected] wrote:

Was that reverted ?


Reply to this email directly or view it on GitHub
#94 (comment)
.

martinmaillard added a commit to martinmaillard/django-rest-framework-json-api that referenced this pull request Apr 21, 2016
When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to
django-json-api#94
and django-json-api#124
martinmaillard added a commit to martinmaillard/django-rest-framework-json-api that referenced this pull request Apr 21, 2016
When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to django-json-api#94 and django-json-api#124
martinmaillard added a commit to martinmaillard/django-rest-framework-json-api that referenced this pull request Apr 21, 2016
When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to django-json-api#94 and django-json-api#124
jerel pushed a commit that referenced this pull request Apr 29, 2016
When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to #94 and #124
jerel added a commit that referenced this pull request Apr 29, 2016
* docs: note about importing serializers

* Document ResourceRelatedField and RelationshipView

* Updated pip install instructions for 2.0.0-beta.2

* Add LimitOffsetPagination

* Dont let the offset go into negative space

* Add basic unit test for LimitOffsetPagination

* Support deeply nested includes
Allow skipping of intermediate included models

* Add current tox.ini directory to PYTHONPATH in order to use imports form there
Fix regression on PY3 caused by unicode_literals

* [FEATURE]: support using get_serializer_class on view

* fixed extract_root_meta for lists

* Fixed get_resource_name in case of non-model backed serializer.

Closes #219

* ResourceRelatedField now accepts serializer methods when many=True

* Rename "suggested" posts to "featured" so we can use suggested as many=True

* Updated SerializerMethodResourceRelatedField to allow many=True

Issue #151
Closes #220

* Correct error responses for projects with different DRF-configurations (#222)

* [#214] Add error messages tests.

* [#214] Extract formatting DRF errors.

* Add example view with custom handle_exception.

* Use HTTP 422 for validation error responses.

* Add full example of class-configured json api view.

* Fixed naming that suggested settings were used to inflect relationship names.

JSON_API_FORMAT_RELATION_NAME actually inflected the `type` instead.
The relation name is not changable at this time although if it woudl
be useful to someone it would be fine to implement it.
Closes #136.

* Updated changelog

* Added a doc note to prefer setting resource_name on serializers or models.

Closes #207

* Added get_related_field_name method to RelationshipView

* Added get_related_field_name method to RelationshipView

* Added docs about field_name_mapping

* Updated the readme for testing (#234)

* Allow exception handler to be used by normal DRF views: (#233)

* Add top-level 'errors' object to non-JSON-API responses
* Allow configuring the exception handler to be used _only_
  in JSON API views or uniformly across all views

* Fix included resource type inconsistency (#229)

When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to #94 and #124

* Fixes #230. Keep write only fields from having an attribute key

* Release v2.0.0

* Update setup.py to classify as production/stable
khornberg pushed a commit to imtapps-dev/django-rest-framework-json-api that referenced this pull request May 2, 2016
When setting `resource_name = None`, the related instance's resource
name is used in `relationships`, but `None` is used in `included`.

This is related to django-json-api#94 and django-json-api#124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants