On 4/18/07, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
> Via 'qs I can access the attribute and  its value.  However, 'data' does
> not provide this extra attributes and value.  Can anybody explain this -
> is there a way I can do this?

Not using the serialization framework. The serializer framework exists
to serialize database objects; extra attributes on the object are not
in the database, and so are not serialized.

An alternative approach is to use the SimpleJSON library directly. Set
up a python dictionary that contains the data structure you want to
serialize (or write a proxy object that behaves like a dictionary),
and pass it to the SimpleJSON library. A similar approach will work
for XML.

> Second Question.
> Using json or xml is there a simple to only return the fields that I
> need in a query set, rather than all the data?

If you pass a fields=(...) option to the serializer, only the fields
named will be serialized. e.g.:

txt = serializers.serialize('json', data, fields=('attr1','attr2'))

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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