[Answered ]-How to deal with many2many using the Django REST Framework

2👍

This creates it’s only table hence I don’t have mapped in my models.

I assume you’re talking about the reverse relationship, as attribute_answers will be accessible from the model instance that it’s defined on, and will create an appropriate default serializer field.

For the reverse relationship, make sure you set the related_name on the model field, so that you can access the reverse relationship from the AttributeAnswers model.

See here: http://django-rest-framework.org/api-guide/relations.html#reverse-relations

Leave a comment