How to serialize Django model in json format if I want to include foreign key models fields?
If I have:
class Model1(models.Model): name=models.C
it's been sometimes that i didn't work on django but is this work for you ?
import simplejson as json data = Model1.objects.get(pk=some_id) to_dump = {'pk': data.pk, 'name':data.name, 'fields':{'field_1':data.child.field_1, 'field_2':data.child.field_2 } } json_data = json.dumps(to_dump)