class Wod(models.Model):
title = models.CharField(max_length=50)
workout = models.CharField(max_length=250)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.title
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Score_Choice(models.Model):
wod = models.ForeignKey(Wod)
choice_text = models.CharField(max_length=200)
def __unicode__(self):
return self.choice_text
class Score(models.Model):
wod = models.ForeignKey(Wod)
user = models.ForeignKey(User)
performed_date = models.DateTimeField('date performed')
**type = Score_Choice.objects.filter(Score_Choice__wod = 'wod')**
score = models.IntegerField()
我有一个带有 Wods 的模型,Score_Choice 引用它来为每个 Wod 分配不同类型的可能分数。
在记录乐谱时,我希望能够参考该世界可用的乐谱类型。
所需的功能是,在输入乐谱时,我选择了我将为其输入乐谱的 wod,然后我将获得该 wod 所需的不同类型的乐谱。