On Thu, 2009-03-19 at 05:17 -0700, Vitaly wrote:
> I wanted json serialize a tree of django model objects: Schedule ->
> Player -> django.models.User.
> django.core.serializers.serialize does shallow serialization of
> QuerySet but I want a deep one. Next, I looked at QuerySet.values()
> plus simplejson but alas the shallow copy again.

So it's not about "copying" -- taking one Python object and creating a
similar, but independent one -- at all. You're talking about how far
down the relation chain we descend when retrieving data.

Bob Thomas has already point out one ticket and there are some others
opened regarding pulling related models in via a values() call
(searching for tickets about values() will reveal a bunch of different
directions and proposals).

Your patch isn't particularly neat (examining the string representation
of the output of type() to determine a class when isinstance() exists,
for example). It also looks like it will fail for infinitely recursive
structures (which exist in practical situations).

Utlimately, though, I think this situation is solved by allowing
select_related() to work with values() -- ticket #5768 is one reference
to that. It's not a trivial problem to solve, but we'll fix it one day.
Multi-valued relations, in particular, require care to make them work
efficiently.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to