Wednesday, January 2, 2019

OneToOneField value must be a model instance, not a value?

Hello everyone!
I am a junior who is first using OneToOneField, I found that the value which is giving to the field only could be a instance of the related model, can't be a value of the field which is specifed by the "to_field" ( else django will raise excption ).
In the other word, "to_field" does not make effect, django performing OneToOneField use PK.
I feel incomprehension and it makes me trouble on working.
Thanks!

--
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+unsubscribe@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/tencent_0C8F5627272A1EB656FAA959560498DB3C05%40qq.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment