I need to serialize a an object that has a foreign key object for example: I have this model:
class Town(models.Model): name = models.CharField(max_length=50) extension = models.IntegerPositiveField() class Restaurant(models.Model): hot_dogs = models.BooleanField() town = models.ForeignKey(Town) from django.core import serializers json_serializer = serializers.get_serializer("json") data = json_serializer.serialize(Restaurant.objects.alI(), ensure_ascii=False) But problem is that when the list of restaurant objects are serialized only the primary key of the town object is serialized but not the name and the extension, this is what I get: [ {pk : '1', hot_dogs: 'True' , town: '1'}, {pk : '2', hot_dogs: 'False' , town: '1'}, {pk : '3', hot_dogs: 'True' , town: '2'} ] And I would want to get the name and the extension of the town foreign key object too. I hope you can help me Thanks in advance. Regards Ariel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.