Link Archive
Currency Conversion using Google and Python
This blog post shows how you might use the Google web service APIs with Python to do currency conversion. It'd be nice if it processed the response using something other than string search/substring, but it's a good start for anybody who needs unofficial currency rates in their project.
http://www.ofn.dk/blog/index.php/2010/02/19/currency-convertion-using-google-and-pyt?blog=5One-Line Browser Detection in Javascript
A single line of JavaScript that that determines the browser of the user. I generally don't use much browser-specific JavaScript these days, but it's nice to know this is there when it's needed. Via Ajaxian
http://www.thespanner.co.uk/2009/01/29/detecting-browsers-javascript-hacks/Rate Limiting in Django via memcache by Simon Willison
Simon Willison has published a fantastic code snippet that provides rate limiting for Django applications using memcache as a storage mechanism to avoid continuous database writes. A very useful addition to a Django project if you're unable to do HTTP throttling at the HTTP level (eg via Apache or your hardware routers/load balances) (via Simon Willison)
http://github.com/simonw/ratelimitcache/tree/masterThe Uswaretech Blog: Using Paypal with Django
A great article on using PayPal within Django. Currently for WhisperGifts I create an encrypted button, however this means the users' end-point is the PayPal website. Using the snippets linked to from this article, the user sees PayPal as a single step and the final end-point is on your own website, giving you more control over the checkout process.
http://uswaretech.com/blog/2008/11/using-paypal-with-django/Tony Hauber: Django Schedule, a pluggable calendar app for Django
Tony Hauber has put together a fantastic pluggable application for Django which allows you to manage events, including recurring events. This will be very useful for an upcoming project where I've hacked together my own recurring event framework that's absurdly messy. Recurring events are hard to get right, but it appears Tony has got it right here.
http://thauber.com/blog/post/django-schedule/James Bennett: Users and the Admin
James Bennett has written this great article on adding user controls to your Django admin screens: Only allow users to see and edit their own content, unless they're a superuser.
A great example of what's possible with the 'new' admin - just don't ignore his wise advice: "that’s a problem no amount of technology will solve for you: if you can’t rely on your site administrators to do the right thing, then they shouldn’t be your site administrators. "
http://www.b-list.org/weblog/2008/dec/24/admin/Jannis Leidel - An autocomplete widget for django-tagging form fields
Jannis Leidel has put together this useful blog post which shows how to use jQuery to provide autosuggest on your django-tagging fields in Django, in both the automatic Admin screens and in your own custom forms.
The only real downside I can see is that it sends the entire tag list with the initial request, so if you have hundreds or thousands of tags then it wouldn't be overly bandwidth-friendly. In those situations it should be relatively easy to modify this to use an XMLHttpRequest, though.
Nice work, Jannis!
http://jannisleidel.com/2008/11/autocomplete-widget-for-django-tagging-form-fields/An offline distraction
One of the many reasons I haven't been online much recently is a new deck out the front of our house, an area which until now was just gravel and mud.
After building it myself over about 3-4 months of weekends I'm glad it's done - and I've got a new-found appreciation for my job and for the job of builders. It's nice to get away from the computer and work on something physical as it gives you instant feedback and a real sense of progress.
My next job is to landscape my (very steep) back yard to turn it into a usable space. I'm guessing by the time I'm done I'll have a great appreciation for landscape gardeners, too :)
http://www.flickr.com/photos/rpoulton/2862125076/in/set-72157607319451969/A Fair Go for Craft Beer - Excise Tax is Killing Craft Beer in Australia!
On top of all the usual taxes any small business pays, Australian craft breweries have to fork out 25% of their sales income straight to the taxation office in the form of excise.
By comparison, small Australian wineries can sell up to $1.7m of wine per year without paying WET. Like wineries, most microbreweries are regional family-owned businesses. By increasing the excise refund for microbreweries to levels closer to that of the wineries, more microbreweries can afford to produce even better beer by employing expert brewers, purchasing better equipment, and accessing better distribution channels.
If you live in Australia, I encourage you to visit one of the petition sites listed and sign this petition before the end of January. As a beer lover and homebrewer, I'd love to see more unique beers on the market here (or, alternatively, have them easier to access - it'd be great to have more micros available in pubs & clubs).
http://www.fairgocraftbeer.com.au/Django Debug Toolbar
David Cramer and Rob Hudson have published a great debugging toolbar that has plug-in 'panels' to give quick access to useful debug tools such as a SQL query list, profiler, cache stats, HTTP POST & GET variables, and more.
I've always included a "debug.html" in my page footer but it only shows me SQL queries and execution time. I think django-debug-toolbar will now quickly become part of the standard toolkit of many serious Django developers, myself included.
Thanks to David & Rob for sharing!
http://www.davidcramer.net/code/280/django-debug-toolbar.htmlDjango 1.0 Released
Django 1.0 has been officially released!
There's a huge list of changes from 0.96, which are covered in the Django 1.0 Release Notes. There's also a fantastic guide to porting your code from 0.96 to 1.0 which will be useful for those not keeping up with trunk.
The release announcement was made today by James Bennett in the Django-Users google group.
Congratulations to everybody who has been involved in the long road to 1.0. This gives us a fantastic base to work from for a stable and prosperous future.
http://docs.djangoproject.com/en/dev/releases/1.0/GenericForeignKeys with Less Queries
Horst Gutmann from Austria has published this fantastic blog post that gives a great performance boost to Django's generic relationships. In a situation where you have an 'Item' table that has a generic relationship to three sub-tables (eg BlogPost, Photo, Link) when you display details from the sub-tables in a for loop there will be n+1 queries - one query for every item shown.
Horst's trick is to first fetch the content-type ID's in one query, then use one query for each subtable - so 4 queries for the above example, regardless of the number of separate Link or BlogPost items you actually have.
This should do a marvellous job for most tumblog style websites, although I imagine if you had a massive number of items the memory usage would probably spike quite high and you'd be better off having duplicate database queries.
http://zerokspot.com/weblog/2008/08/13/genericforeignkeys-with-less-queries/Olympic Medals at the Athens Olympics by Population
Watching a few Olympic events over the weekend I was thinking "I wonder where Australia would be on the winners table at the Olympics if they counted medals by population" - and this morning, via Kottke, I've found a great chart showing just that.
What's cool for me is that Australia are the only top-10 medal winner who are still in the top-10 by population... in fact, we moved up two places. Aussie Aussie Aussie, Oi Oi Oi!
http://www.moreintelligentlife.com/story/an-olympic-gameEasily packaging and distributing Django apps with setuptools and easy_install
This fantastic blog posts shows how easy it is to list your Django applications in Pypi, a Python package registry. The major advantage to this is that future users of your software can just type easy_install mycoolpackage and have your software installed rather than having to download with SVN, move files to the PYTHONPATH, find out why it hasn't worked, etc.
Flash-based Guitar Tuner
I don't play guitar very well, and only pick up my guitar every few months to have a quick fool around with. Every time I touch it it's out of tune, and I spend longer chasing down a good tuning reference point than I do actually playing.
This looks promising... now to teach myself how to do something other than tune the thing and play scales.
http://www.howtotuneaguitar.org/More...
Want to see more? Check out the yearly archives (above left).
