I'm working with the 0.96 release and I'm using json serialization.

Django models serialize just fine, but now I'm interested in
serializing non-model objects and attempts have produced "json can't
serialize" errors.

The svn version of the serialization page (http://
www.djangoproject.com/documentation/serialization/) suggests the
following method:

from django.utils.functional import Promise
from django.utils.encoding import force_unicode

class LazyEncoder(simplejson.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, Promise):
            return force_unicode(obj)
        return obj

No such suggestion exists for the 0.96 version of the page.  Any ideas
on a good, concise 96 alternative?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to