home :: django :: thestateofmoney

Tue, 10 Apr 2012

The state of Django money.

Updated (2012-04-11): Now contains the final and correct pip install command.

TL;DR: 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.

Except.

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.

It turned out Jakewin's py-moneyed was actually a fork of Limist's py-moneyed.

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 discovered there were a set of forks of django-money at github too. I analysed them all, and basically only jakewins's and reinbach's mattered.

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.

[ / django] Trackbacks (0) Comments (0) permanent link permanent link

Trackbacks

Trackbacks are closed for this story.

Comments

Submit a comment

Comments are closed for this story.

About

ॐ (aum) - what was, what is and what will be, wildfire's musings

Anand Kumria
wildfire@progsoc.org

Calendar

Topics

Subscribe

Subscribe to a syndicated feed of my weblog, brought to you by the wonders of Atom.

Music

 

Blosxom

Rendered in only 0.1618 seconds.

Powered by blosxom

Web Standards

Valid XHTML 1.1! Valid CSS! Uses microformats!