I want to know what the difference between these two foreignkey definitions are.
(1) MyFKField = models.ForeignKey(\'MyModel\')
(2) MyFKField = models.Foreig
If the definition of class MyModel is under the definition of class MyFKField (in the code) then you should write it between quotes.
Without quotes, it's a reference to a model either defined within the file or imported via import. With quotes, Django is made responsible for finding the model among all the models in all installed apps.
Django docs states that you would use a string to (1):
model.ForeignKey('self'))model.ForeignKey('app.mymodel'))But in general, specifying the model class directly is clear where it's coming from (2).