Django 1.6中的复杂查询集

2024-05-18 21:23:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发django1.6,我想在Season'sinactive为True时过滤所有Activities

这在下面的模型中是可能的吗? 阶级生产没有季节生产和季节生产的外键

class Activity(models.Model):
    production = models.ForeignKey(Production, null=True, verbose_name='ProductionId')

class SeasonProduction(models.Model):
    season = models.ForeignKey(Season, verbose_name='SeasonId')
    production = models.ForeignKey(Production, verbose_name='ProductionId')

class Season(models.Model):
    name = models.CharField('Name', max_length=255)
    inactive = models.BooleanField(default=True)

class Production(models.Model):
    prod_info = models.CharField('ProductionInfo', max_length=255,
                                       null=True, blank=True)
    title = models.CharField('Title', max_length=255)

Tags: nametrueverbosemodelmodelsnulllengthmax

热门问题