How to return object with its ManyToManyField related object

Viewed 946

I have a model, for example, A has a field xxx (ManyToManyField with B model). How can I query and return like:

{
   'f1': 'xxx',
   'f2': 'yyy',
    photos: [{photo1}, {photo2},...]
}

Any help is appreciated. I'm django newbie :D

2 Answers
Related