Django Unique Together (with foreign keys)

后端 未结 6 843
独厮守ぢ
独厮守ぢ 2020-11-28 11:35

I have a situation where I want to use the Meta options of unique_together to enforce a certain rule, here\'s the intermediary model:



        
6条回答
  •  悲哀的现实
    2020-11-28 12:25

    From django 2.2+ versions, it is suggested to use constraint & Index as model class meta option:

    https://docs.djangoproject.com/en/2.2/ref/models/options/#django.db.models.Options.unique_together

    https://docs.djangoproject.com/en/2.2/ref/models/options/#django.db.models.Options.constraints

提交回复
热议问题