Python django 1.6中的复杂查询集
我正在开发django 1.6,我想在季节不活动为真时过滤所有Python django 1.6中的复杂查询集,python,django,django-queryset,foreign-key-relationship,Python,Django,Django Queryset,Foreign Key Relationship,我正在开发django 1.6,我想在季节不活动为真时过滤所有活动 这是可能的模型如下? 阶级生产并没有季节生产和季节的外键 class Activity(models.Model): production = models.ForeignKey(Production, null=True, verbose_name='ProductionId') class SeasonProduction(models.Model): season = models.ForeignKey(
活动
这是可能的模型如下?
阶级生产并没有季节生产和季节的外键
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)
试试这个:
season_prods = SeasonProduction.objects.filter(season__inactive=True)
activities = Activity.objects.filter(
production__in=season_prods.values('production_id'))
相关文档链接:
请问您为什么使用Django 1.6。它过时了,而且有缺陷。因为项目在django 1.6@gitbrum中,您可以发布生产版模型定义吗?@gitbrull请查看我的编辑。非常感谢!)