Skip to content

Viewset list when using polymorphic models #400

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

Closed
adsized opened this issue Jan 15, 2018 · 2 comments
Closed

Viewset list when using polymorphic models #400

adsized opened this issue Jan 15, 2018 · 2 comments

Comments

@adsized
Copy link
Contributor

adsized commented Jan 15, 2018

I have been trying to get the support for polymorphic model serialization to work in my latest project. When I request a specific object from my endpoint, the correct serializer is clearly instantiated and I receive the output that I would expect. When I try and retrieve a list of model instances, however, the following exception is raised:


Request Method: GET
Request URL: http://localhost:8000/projects
Django Version: 1.11
Exception Type: AttributeError
Exception Value: 'list' object has no attribute '_meta'
Exception Location: django-rest-framework-json-api/rest_framework_json_api/serializers.py in get_polymorphic_serializer_for_instance, line 279

I have tried running the example project, provided in the repo, and I'm able to reproduce the error I have been seeing.

Looking in the documentation, it is not clear whether there is currently support for serializing multiple model instances in a viewset list output. Looking at the tests for the project, I also do not see a test for this scenario.

Is this something that should be supported?

@mblayman
Copy link
Collaborator

Is this fixed by #402 being merged?

@adsized
Copy link
Contributor Author

adsized commented Jan 16, 2018

Just checked and the master branch now works great! Many thanks for merging the changes!

@adsized adsized closed this as completed Jan 16, 2018
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

No branches or pull requests

2 participants