Try to search your question here, if you can't find : Ask Any Question Now ?

Specifying model relationship as string vs concrete model?

HomeCategory: stackoverflowSpecifying model relationship as string vs concrete model?
Avatarjohn asked 5 months ago

Since Django provides two ways of specifying model relationship,

models.ForeignKey('User') vs models.ForeignKey(User)

Which one is more preferred and recommended? Is there any upside or downside of choosing one over the other? In Django documentation, all the example are of the second form but I have seen many people specifying the relationship as a string.

1 Answers
Best Answer
AvatarFernando answered 5 months ago
Your Answer

5 + 1 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com