Django: “Soft” ForeignField without database integrity checks

前端 未结 6 1317
南旧
南旧 2021-02-05 17:05

I have a Django project that has multiple django \"apps\". One of them has models to represent data coming from an external source (I do not control this data).

I want m

6条回答
  •  执念已碎
    2021-02-05 17:33

    If you just want to disable the ForeignKey constraint check on a field, then just add db_constraint=False to that field.

    user = models.ForeignKey('User', db_constraint=False)
    

    See also: Django - How to prevent database foreign key constraint creation

提交回复
热议问题