I have real estate model. There are two fields price and currency. People can enter real estate's price in two currency only. However as price field is just numbers and prices are linked to currency, I can not order prices with different currency. Only ordering with the same currency is possible.
Only two currency options are available:
UZS = 'UZS'
USD = 'USD'
CURRENCY_TYPES = (
(UZS, 'sum'),
(USD, 'y.e.')
)
class Property(BaseModel):
price = models.PositiveIntegerField()
currency = models.CharField(max_length=255, choices=CURRENCY_TYPES)
I tried to change prices to the same currency but then I don't know how to order them.
Property.objects.filter(currency='UZS').annotate(divided_price=F('price') / 10000).values('divided_price')
So rate is
1 USD = 10 000 UZS
10 000 UZS = 1 USD
How to order prices with different currencies?