2017-02-23 12 views
0

私はdjango 1.6で作業しています。シーズンの非アクティブをTrueにすると、すべてActivitiesをフィルタリングしたいと思います。djangoの複雑なクエリーセット1.6

これは次のモデルでも可能ですか? クラスProductionはSeasonProductionとSeasonに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) 
+0

season_prods = SeasonProduction.objects.filter(season__inactive=True) activities = Activity.objects.filter( production__in=season_prods.values('production_id')) 

関連ドキュメントへのリンクを。それは時代遅れでバグです。 –

+0

プロジェクトがdjango 1.6になっています@gitblame – mark

+0

'Production'モデル定義を投稿できますか? –

答えて

0

この試してみてください:あなたはDjangoの1.6を使用している理由は、私が聞いても

+0

ありがとうございます! :) – mark

関連する問題