I\'m having a problem with multi-table inheritance in django.
Let’s make an example with bank accounts.
class account(models.Model):
name = models……
To the best of my knowledge there isn't a Django built-in way to do this.
However, given acc=account.object.get(pk=29)
, you can use:
try:
typeA = acc.accounttypeA
# acc is typeA
except accounttypeA.DoesNotExist:
# acc should be typeB if account only has typeA and typeB subclasses
try:
typeB = acc.accounttypeB
# acc is typeB
except accounttypeB.DoesNotExist:
# acc should be typeA if account only has typeA and typeB subclasses