1👍
If you have only one Bar
object per Foo
then use OneToOne relation. If it can be more than one Bar
for single Foo
then use ForeignKey.
As for “reverse” statement:
# access to Bar property of Foo in OneToOne relation
foo.bar
# access to first Bar property of Foo in ForeignKeyRelation
foo.bar_set.all().first()
In both cases it will be one SQL query, but OneToOne version looks better 🙂
Source:stackexchange.com