Django: Why are quotes around the model in a ForeignKey definition

后端 未结 3 1313
一向
一向 2020-12-28 21:51

I want to know what the difference between these two foreignkey definitions are.

(1) MyFKField = models.ForeignKey(\'MyModel\')
(2) MyFKField = models.Foreig         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 22:23

    If the definition of class MyModel is under the definition of class MyFKField (in the code) then you should write it between quotes.

提交回复
热议问题