Fix/auto prefetch with m2m #333
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously including relations with the optimised viewset through m2m's would crash as it was not correctly getting the model from the related descriptor
For example from the tests:
The tests already covered the right use case, but were not using the prefetching viewset.
I had to update the test models / serializers slightly to support the auto prefetching (which requires the field names in the serializer match the models). I will create an issue to address this as an improvement