Here's the deal:
I got two db models, let's say ShoppingCart
and Order
. Following the DRY principle I'd like to extract some common props/methods into a shared interface ItemContainer
.
Everything went fine till I came across the _flush()
method which mainly performs a delete on a related object set.
class Order(models.Model, interface.ItemContainer):
# ...
def _flush(self):
# ...
self.orderitem_set.all().delete()
So the question is: how do I dynamically know wheter it is orderitem_set
or shoppingcartitem_set
?