Is it possible to detect that field in Django model has been changed?
class Product(models.Model):
my_current_price = MoneyField(max_digits=20, decimal_places=2, null=True, blank=True,
verbose_name=_('My original price'))
my_eur_price = MoneyField(max_digits=20, decimal_places=2, null=True, blank=True, verbose_name=_('My price in EUR'))
my_usd_price = MoneyField(max_digits=20, decimal_places=2, null=True, blank=True, verbose_name=_('My price in USD'))
The thing is that I need to recalculate EUR and USD price anytime when my_current_price
is changed.
I have two ideas:
Somehow override
MoneyField
and send signal when the field is changed.Override save method and create a new attribute
__my_current_price
like here - this works but it makes code very unclear for me.
EDIT: I store the price in different currencies because of faster database lookups.