1👍
✅
As usual in all python instancemethods, the current instance is the first positional parameter, canonically named self
:
class MyModel(models.Model):
# fields etc here
def clean(self):
print("current instance is {}".format(self))
EDIT:
Since you clarified the question, it seems that what you want is the current instance’s related storage
, not the Consumption
instance itself (which is self
). And quite simply, since the current instance is self
, the related storage
instance is self.storage
.
Source:stackexchange.com