OneToOne mappings

17 views
Skip to first unread message

marcin....@gmail.com

unread,
Mar 13, 2017, 10:38:38 AM3/13/17
to Django users
Hi.

The problem is:

A   1:1   B
B.a = OneToOne(A)

and there is a vA - an unmanaged model of A's view


A and B are linked together.
vA view is not linked with B, of course.

When I try to declare OneToOne within vA, Django expects vA.b_id field which is missing (that's ok).
When I try to declare sedond OneToOne within B (with db_column set to B.a_id and on_delete=DO_NOTHING),  Django complains about "models.E007": column name 'a_id that is used by another field.
When I declare second 1:1 and ignore models.E007, I can't save B model anymore due to "many assignments to the same column" (these values are same and will be always same, but "Django knows better").

So how to map a relation for my view? Is Django really so limited? 

Marcin
Reply all
Reply to author
Forward
0 new messages