Tue, 10 Apr 2012
Updated (2012-04-11): Now contains the final and correct pip install command.
pip install django-money will give you a working set of Django fields that handle Money and Currency. Read below for how that happened.
I began this Easter weekend trying to finish up one of my pet-projects and get it ready to publish. The goal of the website is to compare providers, of the same thing, from around the world.
Representing prices is simple. A float will do if you are in a hurry.
When you need to perform calculations and you run into rounding errors. At that point you will likely discover the Decimal module.
Which also works perfectly fine. And if you only ever deal in a single market that is fine.
But across markets? That requires Money. Money is normally defined as a value and currency. Once you have both of those, you can then do cross-market comparison – and upgrade you program to handle multi-currency – easily.
I hoped that I was not the only person who had realised this, so I started to look around.
And I struck gold! I found Python Money. It even included appropriate Django fields as well.
Unfortunately it had had no updates since 2008. ☹. Worse it didn't work so well. I continued my search.
I kept on looking and found Django Money. Even better. This separated out the Django support and the Python support.
So I set about retrieving every fork and comparing them.
It turns out that Jakewin's version was good, just out-of-date. It mentioned waiting until a pull request has been merged in to limist's version.
Which had been done a while ago. And Jakewin's Django-money (djmoney) was nicely done too, unittests and all. It had just bitrotted compared to newer versions of Django (and South).
I created fixes for jakewins and reinbach's version.
I also opened up on an issue asking limist's to tag and upload a new version of py-moneyed.
I also got a response from limist and now you can do
pip install py-moneyed and get a useful, working, version.
And reinbach also responded and now you can do
pip install django-money and get a working, usable, representation of Money within Django.
It turned out to be a productive, if yak-shaving, weekend after all.
Trackbacks are closed for this story.
Comments are closed for this story.
ॐ (aum) - what was, what is and what will be, wildfire's musings
Subscribe to a syndicated feed of my weblog, brought to you by the wonders of Atom.
Rendered in only 0.2135 seconds.