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 -
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 -
Create/update function for CLSQL
Django has a very handy model method in its database library called get_or_create, which either creates a new record using the keyword arguments passed as field values or gets a record using the arguments passed. Submit article
May 9th, 2008 | Filed under Programming -
Threading in Django
Profitable use of threading in web development is rare, particularly when contending with Python’s global interpreter lock. There are a few notable exceptions to this. Submit article
Mar 7th, 2008 | Filed under Software