Re: ForeignKeys and select_related

2009-01-18 Thread Preston Holmes
So just for completeness, here is the bit about avoiding the inner for loop in this situation: On Jan 17, 8:40 am, ptone wrote: > matching_torrents = Torrent.objects.filter(name__icontains='x360') > my_data = [] > for a_torrent in matching_torrents: >     info_objects = a_torrent.torrentInfo_se

Re: ForeignKeys and select_related

2009-01-17 Thread cptnwinky
Woops, nevermind. I found an error in my code above that. Sorry. On Jan 17, 12:28 pm, cptnwinky wrote: > Wow, this list is amazing. I've been asking questions on various > python forums and never getting even a response. You all have helped > me immensely and I really do appreciate it. > > Now,

Re: ForeignKeys and select_related

2009-01-17 Thread cptnwinky
Now this is strange... >>> from torrent.search.models import Torrent >>> matching_torrents = Torrent.objects.filter(name__icontains='x360') >>> >>> for a_torrent in matching_torrents: ... dir(a_torrent) Produces this (of course more than once)... ['DoesNotExist', 'MultipleObjectsReturned',

Re: ForeignKeys and select_related

2009-01-17 Thread cptnwinky
Wow, this list is amazing. I've been asking questions on various python forums and never getting even a response. You all have helped me immensely and I really do appreciate it. Now, I suppose I should pay it forward by paying close attention to this list and helping others where I can. --~--~---

Re: ForeignKeys and select_related

2009-01-17 Thread ptone
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 (

Re: ForeignKeys and select_related

2009-01-17 Thread cptnwinky
Ah, I think I see. Thank you so much for your help. --~--~-~--~~~---~--~~ 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 gro

Re: ForeignKeys and select_related

2009-01-17 Thread Daniel Roseman
On Jan 17, 3:35 pm, cptnwinky 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 res

Re: ForeignKeys and select_related

2009-01-17 Thread cptnwinky
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 --~--~-~--~~~---~--~~ Yo

Re: ForeignKeys and select_related

2009-01-16 Thread Karen Tracey
On Sat, Jan 17, 2009 at 12:12 AM, cptnwinky wrote: > > Once again, thanks all for the help, I really do appreciate it. > > Karen, I've read that page at least 10 times in the past 24 hours. > Perhaps I just don't understand it though. The problem is that using > "filter" returns a queryset which

Re: ForeignKeys and select_related

2009-01-16 Thread cptnwinky
Once again, thanks all for the help, I really do appreciate it. Karen, I've read that page at least 10 times in the past 24 hours. Perhaps I just don't understand it though. The problem is that using "filter" returns a queryset which does not contain the *_set function that using "get" supplies.

Re: ForeignKeys and select_related

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 20:26 -0800, cptnwinky wrote: > Thanks for replying. > > I don't mean to sound crass but I did mention what the problem was. > > Quote: > I've even tried specifying in select_related which exact tables and > fields I want returned however, only the results from Torrent tabl

Re: ForeignKeys and select_related

2009-01-16 Thread Karen Tracey
On Fri, Jan 16, 2009 at 11:26 PM, cptnwinky wrote: > > Thanks for replying. > > I don't mean to sound crass but I did mention what the problem was. > > Quote: > I've even tried specifying in select_related which exact tables and > fields I want returned however, only the results from Torrent tabl

Re: ForeignKeys and select_related

2009-01-16 Thread cptnwinky
Thanks for replying. I don't mean to sound crass but I did mention what the problem was. Quote: I've even tried specifying in select_related which exact tables and fields I want returned however, only the results from Torrent table is returned. The problem is it only returns results from the To

Re: ForeignKeys and select_related

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 13:21 -0800, cptnwinky wrote: [...] > I'm trying to perform a icontains search on the name field of the > Torrent class. I need it to also return, with each result, it's > corresponding trackers, seeds, leeches and downloads. Here is the > relevant line in my view... > > res

ForeignKeys and select_related

2009-01-16 Thread cptnwinky
This problem has been racking my brain for days now, I suppose it's time to ask for help. I should point out that I'm really new to both python and django. I have the following model... from django.db import models class RSSFeed(models.Model): name = models.CharField(max_length=255) url