I'm working on a project where user adds many products and compare their prices, average price, minimal and many other statistics. There are two currencies for now, EUR and CZK. I'm here to ask you for advices - either about performance or a better structuring of my code. There are for example 10 prices of one product on it's dashboard page. To be able to compute average price, minimal etc, I'm converting all prices to EUR price, then compute the property (AVG,MIN etc) and then show this property in currency which user set. (They can set either EUR, CZK or original currency).I feel that this is probably too expensive (according to performance) but I can't figure out a better approach.Modelsclass Currency(models.Model):    shortcut = models.CharField(max_length=20,choices=(('eur','EUR'),                                                       ('czk','CZK')))    special_sign = models.CharField(max_length=10, blank=True, null=True)    class Meta:        verbose_name_plural = Currencies    def __unicode__(self):        return self.shortcutclass Price(models.Model):    currency = models.ForeignKey('Currency',related_name='prices')    amount = models.DecimalField(max_digits=10,decimal_places=2)    def __unicode__(self):        return u'{} {}'.format(self.amount,self.currency)    def to_eur(self):        if self.currency.shortcut=='eur':            return self.amount        elif self.currency.shortcut=='czk':            return Exchange.objects.first().czk_to_eur(self.amount)    def to_czk(self):        if self.currency.shortcut == 'czk':            return self.amount        elif self.currency.shortcut == 'eur':            return Exchange.objects.first().eur_to_czk(self.amount)    @property    def eur_price(self):        if self.currency.shortcut=='eur':            return self.amount        elif self.currency.shortcut=='czk':            return self.to_eur()    @property    def czk_price(self):        cents = decimal.Decimal('01')        if self.currency.shortcut == 'czk':            return (self.amount).quantize(cents, decimal.ROUND_HALF_UP)        elif self.currency.shortcut == 'eur':            return self.to_czk()    @property    def pref_currency_amount(self):        pref_currency = self.scan.occurence.product.user.userprofile.preferred_currency        if pref_currency:            if pref_currency.shortcut == 'czk':                return self.czk_price            else: return self.eur_price        return self.amount    @property    def pref_currency_string(self):        pref_currency = self.scan.occurence.product.user.userprofile.preferred_currency        # return pref_currency.shortcut        if pref_currency:            if pref_currency.shortcut.lower() == 'czk':                return u'{} {}'.format(self.czk_price, pref_currency.shortcut)            else:                return u'{} {}'.format(self.eur_price, pref_currency.special_sign)        return u'{} {}'.format(self.amount,self.currency.special_sign)    def get_price(self,currency):        if currency=='eur':            return self.eur_price        elif currency=='czk':            return self.czk_price    def get_exchanged_price_string(self):        if self.currency.shortcut=='czk':            return u'{} {}'.format(Exchange.czk_to_eur(self.amount),u'')        else:            return u'{} {}'.format(Exchange.eur_to_czk(self.amount),'CZK')    def get_original_price_string(self):        if self.currency.shortcut=='czk':            return u'{} {}'.format(self.amount,u'')        else:            return u'{} {}'.format(Exchange.eur_to_czk(self.amount),'CZK')SHORTEN MODELclass Occurence(models.Model):    product = models.ForeignKey(Product, related_name='occurences', on_delete=models.CASCADE)    currency = models.ForeignKey('Currency',related_name='occurences')    site = models.ForeignKey(Site, related_name='occurences', on_delete=models.CASCADE)    def stats_get_min_price(self):        scan = self.get_min_scan()        if scan:            price = scan.price.eur_price        else:            price = None        return {'price': price,                'xml_tag': '<min_price>',                'xml_close_tag': '</min_price>',                'label': 'Min'}    def stats_get_avg_price(self):        prices = [x.price for x in self.scans.all() if x.price]        if prices:            price = math_ops.round_eur(decimal.Decimal(sum([x.eur_price for x in prices]) / len(prices), 2))        else:            price = None        preferred_currency = self.product.user.userprofile.preferred_currency        if preferred_currency:            if preferred_currency.shortcut == 'czk':                amount = Exchange.eur_to_czk(price)                pref_currency_string = '{} CZK'.format(amount)                pref_currency_amount = amount            else:                amount = price                pref_currency_string = u'{} '.format(amount)                pref_currency_amount = amount        else:            if self.currency.shortcut == 'czk':                amount = Exchange.eur_to_czk(price)                pref_currency_string = '{} CZK'.format(amount)                pref_currency_amount = amount            else:                amount = price                pref_currency_string = u'{} '.format(amount)                pref_currency_amount = amount        return {'price': price,                'pref_currency_string':pref_currency_string,                'pref_currency_amount':pref_currency_amount,                'xml_tag': '<average_price>',                'xml_close_tag': '</average_price>',                'label': 'AVG'}THEN IN TEMPLATES (OR TABLES)class OccurencesTable(tables.Table):    avg_price = tables.columns.TemplateColumn({{ record.stats_get_avg_price.pref_currency_string }},accessor='stats_get_avg_price.price', verbose_name='AVG price')    last_scan_price = tables.columns.TemplateColumn({{ record.get_last_scan.price.pref_currency_string }} ,accessor='get_last_scan.price.amount', verbose_name='Last scan price')    difference = tables.columns.TemplateColumn({% load static %}{% with diff=record.stats_get_difference_for_two_last_scans.percent %}                {% if diff > 0 %}+{% endif %}{{ diff }} % <img style=height: 15px src={% if diff < 0 %}{% static img/icons/arrow-trend-minus.png %}{% elif diff == 0 %}{% static img/icons/arrow-trend-normal.png %}{% else %}{% static img/icons/arrow-trend-plus.png %}{% endif %}>                {% endwith %},verbose_name='Difference')I would like to hear your thoughs, should I do something better?
Working with multiple currencies in Django
python;django