mirumee / django-prices

Django fields for the prices module
158 stars 52 forks source link

Currency column #7

Closed daGrevis closed 11 years ago

daGrevis commented 11 years ago

After looking at generated SQL, I'm surprised! Where is the column for currency?

>>> Item.objects.all()[0]
<Item: name: Kkāds štrunts, price: Price('0.01', currency='LVL')>
>>> i = Item.objects.all()[0]
>>> from prices import Price
>>> p = Price("1.0", currency="USD")
>>> i.price = p
>>> i.save()
>>> i = Item.objects.all()[0]
>>> i.price
Price('1', currency='LVL')

Another place where it's possible to shoot yourself in the foot. A fix would be to add an exception when column is set to Currencyobject that has different currency than the one set in model definition.

What do you think? Thanks!

patrys commented 11 years ago

The field is what holds the currency. We're planning to add a field that can store an arbitrary price along with its currency later on.

Will amend it to check the currency, that sure is a valid issue.

daGrevis commented 11 years ago

Can I fix it?

patrys commented 11 years ago

Will gladly accept a pull request that results in a ValueError.

patrys commented 11 years ago

Should be fixed in 0.2.2.