In my django app I have a model with such method:
def deleteItem(self, item, pt):
if pt == 'product':
i = self.vcartitem_set.filter(product__id=item)
elif pt == 'brand':
i = self.vcartbrand_set.filter(brand__id=item)
else:
return u'Wrong product type'
i.delete()
return 'OK'
I have 2 databases, 'default' and 'slave'. Slave is read-only, so when self.vcartitem_set.filter(product__id=item) is performed using 'slave' database, I have an error on i.delete(). I can bypass this by writing i.delete(using='default'), but then I have to write that for every model. Is there a way to tell django to perform all write operations, using 'default' DB, even if objects were previously retrieved using 'slave' DB?