django-piston: how to get values of a many to many field?
问题 I have a model with ManyToManyField to another model. I would like to get all the info on a particular record (including the related info from other models) return by JSON. How to get django-piston to display those values? I would be happy with just primary keys. Or can you suggest another option ? 回答1: I may be wrong, but this should do it: class PersonHandler(BaseHandler): model = Person fields = ('id', ('friends', ('id', 'name')), 'name') def read(self, request): return Person.objects