I'm not sure if this is any closer, but maybe it is:

queryset = Quote.objects.filter(source in
series.tvepisode_set.select_related()),

There's something wrong with the "source in" part, though...

On May 16, 3:39 pm, Alex <[EMAIL PROTECTED]> wrote:
> I'm playing around with a TV quotes database and I'm trying to get all
> quotes from one TV series. My problem is that the quotes are directly
> tied to an episode of a TV series, not the series itself. How can I
> easily get a queryset that represents all quotes from that series?
>
> Here's a snippet from my models.py (removing irrelevant info):
>
> class Source(models.Model):
>     name = models.CharField(max_length=50)
>     slug = models.SlugField(max_length=20)
>
> class Quote(models.Model):
>     quote = models.TextField(max_length=500)
>     authors = models.ManyToManyField(Author)
>     source = models.ForeignKey(Source)
>
> class TVSeries(models.Model):
>     name = models.CharField(max_length=50)
>     slug = models.SlugField(max_length=20, editable=False)
>
> class TVEpisode(Source):
>     series = models.ForeignKey(TVSeries)
>     episodenum = models.IntegerField()
>
> In my view, I'm thinking of something like the following, which
> obviously doesn't work:
>
> queryset =
> Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug)))
>
> Is there an easy way to filter by groups like this?
>
> Thanks,
> Alex
--~--~---------~--~----~------------~-------~--~----~
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