Using the class means you have to import it first. I have stuck to the string 
version since encountering circular import errors some time ago. Django is 
smart enough to get it right so I don't even think about it.

YMMV

Mike

Connected by Motorola

Mohit Solanki <mohitsolanki...@gmail.com> wrote:

>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. Can Someone please elaborate more on this?
>
>
>Regards,
>
>
>Mohit
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at https://groups.google.com/group/django-users.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/06988f5c-9ad0-47b1-9216-5f689abb1720%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/rbtrryas0cl949dqomv4rvbs.1554611799912%40email.android.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to