Sunday, September 4, 2011

foregin keys

hi, how do i join two models on something OTHER then the primary key?

i have two models:
class tv_shows(models.Model):
        name = models.CharField(max_length=64)
        show_type = models.CharField(max_length=16,default='tvshow')
        last_eps = models.CharField(max_length=10)
        last_checked = models.DateTimeField(auto_now=True)
        air_time = models.IntegerField(default = 0)
        def __unicode__(self):
                return self.name

class eps_data(models.Model):
        show = models.ForeignKey('tv_shows')
        air_date = models.DateTimeField("Show Air Date")
        eps_name = models.CharField("Episode Name",max_length=256)
        eps_number = models.CharField("Episode Number",max_length=16)
        css_markup = ""
        class Meta:
                unique_together = (("show","eps_number"))

but i don't want to join on tv_shows.id i want to join on tv_shows.name, how do i do that?

--
Thanks
Kevin Anthony
www.NoSideRacing.com

Do you use Banshee?
Download the Community Extensions:

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment