Django serializing Queryset with related entity fields

后端 未结 1 1661
孤独总比滥情好
孤独总比滥情好 2021-01-16 08:16

I\'m trying to join 2 entities, get specific fields from them, and return a JSON of that.
I tried writing the following code:

import datetime
result         


        
相关标签:
1条回答
  • 2021-01-16 08:34

    As far as I know, django built-in serializers cannot work with model related fields. Take a look at:

    • DjangoFullSerializers
    • this answer and suggested serializer
    • relevant open ticket in django issue tracker

    Also see:

    • Django serialization of inherited model
    • Serialize django models with reverse One-To-One fields to JSON

    Hope that helps.

    0 讨论(0)
提交回复
热议问题