Hi everyone,
How can I get foreign key fields serialized ?
I can't get the desired effect with:
select_related() or
Book.objects.extra(select={'firstname': 'subselect for firstname',
'lastname',' subselect for lastname' })
but don't want to iterate over the whole queryset unnecessarily.
Model
class Author( models.Model):
firstname = models.CharField(maxlength=255)
lastname = models.CharField(maxlength=255)
class Book( model.Model):
title = model.CharField(maxlength=255)
author = models.ForeignKey(Author)
....
mylist = Book.objects.all()
jstr = serializers.serialize('json', mylist )
The author_id will be in jstr but I want to get firstname and lastname
in there too.
Many Thanks,
Greg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---