Let's say I have:
class Restaurant(Model):
pass
class Table(Model)
restaurant = ForeignKey(Restaurant)
class Chair(Model)
restaurant = ForeignKey(Restaurant)
table = ForeignKey(Table)
Is there a best practice for ensuring that the chair assigned to a table is always from the same restaurant? These models above assume that we might have spare chairs not yet assigned to tables.
My actual case is more like this:
class A(Model):
pass
class B(Model):
a = ForeignKey(A)
class C(Model):
a = ForeignKey(A)
class D(Model):
b = ForeignKey(B)
c = ForeignKey(C)
And I want to ensure b.a == c.a.
(I think I just have to manually add db sql constraints in my migrations and also override save())
Rich