Skip to content

Instantly share code, notes, and snippets.

@mitchdowney
Created April 8, 2014 15:44
Show Gist options
  • Save mitchdowney/10145492 to your computer and use it in GitHub Desktop.
Save mitchdowney/10145492 to your computer and use it in GitHub Desktop.
how do i filter the models to pass all quotes from one podcast?
class Podcast(models.Model):
title = models.CharField(max_length=200)
description = models.TextField(blank=True)
image = models.FileField(upload_to=get_upload_file_name, blank=True)
homepage = models.URLField(blank=True)
donate_url = models.URLField(blank=True)
# categories = ...
# keywords = ...
# followers = ...
def all_podcast_quotes(self):
return Quote.objects.filter(episode__podcast=self)
def __unicode__(self):
return unicode(self.title)
class Episode(models.Model):
podcast = models.ForeignKey(Podcast)
title = models.CharField(max_length=200)
publication_date = models.DateField()
description = models.TextField(blank=True)
episode_link = models.URLField(blank=True)
image = models.FileField(upload_to=get_upload_file_name, blank=True)
# duration = what type of field for length of episode data? needs to match up with format for quote.time_quote_begins and quote.time_quote_ends
# keywords = ...
def __unicode__(self):
return u'%s - %s' % (self.podcast.title, self.title)
episode = models.ForeignKey(Episode)
persons_quoted = models.ManyToManyField(PersonQuoted)
text = models.TextField(blank=True)
time_quote_begins = models.IntegerField()
time_quote_ends = models.IntegerField(blank=True)
tags = models.ManyToManyField(Tag, blank=True)
# submitted_by = ...
# vote = ...
def get_absolute_url(self):
return reverse('home')
def __unicode__(self):
return u'%s - %s' % (self.episode.podcast.title, self.episode.title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment