django開發中關於外鍵設置
我們建模型的時候會用到ForeignKey
而由於外鍵的約數會導致一些保存
所有我們ctrl+左鍵進入源碼
源碼
def __init__(self, to, on_delete=None, related_name=None, related_query_name=None,
limit_choices_to=None, parent_link=False, to_field=None,
db_constraint=True, **kwargs):
我們要把源碼中的db_constraint
設置成Flase這樣就有關聯關系,但是不會受他約數