django開發中關於外鍵設置


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這樣就有關聯關系,但是不會受他約數


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM