Hi all,
I'ìm trying to use json encoding to pass data from a django view to
a jquery based grid template. I have a model like this
class Client(models.Model):
name = models.CharField('Nome', max_length=30)
surname = models.CharField('Cognome', max_length=30)
def __unicode__(self):
return "%s %s" % (self.surname.capitalize
(),self.name.capitalize())
def _full_name(self):
return "%s %s" % (self.surname.capitalize
(),self.name.capitalize())
full_name = property(_full_name)
When serialize the Client list i use (in my view) the following code:
contact_list = Client.objects.all()
serializers.serialize('json', contact_list, fields=
('id','name','surname','full_name')
but i obtain this output
[{"pk": 1, "model": "anagrafica.client", "fields": {"surname":
"Verdi", "name": "Andrea"}}, {"pk": 2, "model": "anagrafica.client",
"fields": {"surname": "d2", "name": "Dolci Fritti"}}]
So it seems that my property full_name isn't serialized at all. How
can I solve the problem?
Thanks,
nelson
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---