Archives
-
Runtime ChoiceField filtering in Django’s admin
Django 1.x brought with it much finer grained control over the admin application with admin forms and inline form sets. However, I still keep running into the same problem that I have since I started using Django – you cannot provide a limited queryset for a select field that depends on other instance variables. Submit [...]
Jul 31st, 2009 | Filed under Programming -
MultiFormDict
For the moment, I am stuck on Django 0.96 on one of our servers at work, but needed the formset functionality from the newer forms module. It is a common problem and easily dealt with by prepending keys with a common token to group forms’ values together. I ended up writing a little derived class [...]
Jan 11th, 2009 | Filed under Programming -
Python in NetBeans
For the past few weeks I’ve been using the NetBeans (with the new Python module) as my primary IDE. I generally use TextMate, which is more than an editor and less than the kitchen sink, lying somewhere between BBEdit and Emacs. TextMate is fast and a pleasure to use, but lately I have found myself in need of something a little more robust.
Dec 13th, 2008 | Filed under Programming -
Django Caching with Backups
Django’s cache is useful to speed up access to data from slow sources, such as a remote RSS feed. But if the remote source becomes inaccessible, the data disappears after the cache expires it. One solution is to store the data longer, but that can lead to stale data. Another solution is to keep two [...]
Nov 12th, 2008 | Filed under Programming -
Mutable default parameter values in Python
In Python, everything is an object. Variables are technically names for references to objects. Therefore, when passing an argument to a function, what is in fact being passed is the value of the reference. This leads to some useful techniques. Submit article
Jul 22nd, 2008 | Filed under ProgrammingTags: python