As another person new to this, let me take a stab at this from a
newcomers perspective.

The result of the Torrent.objects.filter* statement returns a QuerySet
object, which in a way is just a list of Torrent object instances,
with a bunch of functions to further work with that list of instances
(further filter, etc).

You need to loop over each Torrent instance to get its related
information and build the complex data structure you are seeking.  In
other words while you can follow the relationship for a single
torrent, you can't, in one statement, retrieve that information in one
statement.

So in pseudocode (because I don't know Django well enough to rattle
this off).

matching_torrents = Torrent.objects.filter(name__icontains='x360')
my_data = []
for a_torrent in matching_torrents:
    info_objects = a_torrent.torrentInfo_set.all()
    seeds = []
    for a_info in info_objects:
        seeds.append(a_info.seed)
    my_data.append((a_torrent.name,seeds))

etc with your other related data - you'd end up with your lists of
tuples style datastructure however you want to design it.  But I'm
pretty sure Django has no way to return this sort of complex multi
attributes from multi related objects data structure in one fell
swoop.

Now I'm sure there is a way to avoid that inner for loop above and get
a list of *non-related* attributes directly from the queryset, but the
above would be the verbose way.

Remember I'm new too, and this is just my attempt to give conceptual
help as I understand it.

-P



On Jan 17, 7:35 am, cptnwinky <cptnwi...@gmail.com> wrote:
> Thanks once again Karen. Could you throw me a bone though and explain
> how I extract the instance? I'm rather new to python and django; I
> come from a PHP background so I'm used to results from a db being
> rather straightforward.
>
> Thanks,
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to