Slaptijack Title

Archive for 2010

Python: Convert String Date to Date Object

Occasionally, you may run across a date in a format that can't be easily loaded into a Python date object. For example, I recently had a situation where a file I was parsing was full of dates in this format: 7/7/2008.

Categories: Programming

Combining Multiple Models Into One Context Variable

I'm not sure if the title of this post accurately describes the problem. I have a situation where I have very similar models that I want to display in one table. As you know, querysets are limited to a single model, so it isn't possible to have a single context variable use a single queryset. In my case, I could have created a new context variable for each model, but that results in a situation where adding a new model means changing both the view and the template.

Categories: Programming

Django + jQueryUI Tabs: Open a Specific Tab on Page Load

I recently created a page that had different tabs using the jQueryUI Tabs widget. For whatever reason, I would occasionally want to show a specific tab on page load rather than the default initial tab. One way to do this is to set a variable in your view context and then use jQuery to open the right tab.

Categories: Programming

Django Debug Toolbar Multiple Database Support

Django Debug Toolbar (DjDT) is a must-have tool for most Django developers (at least the ones I know!). One of the most useful features of DjDT is the SQL Debug Panel that displays information about SQL queries including execute time and EXPLAIN output.

Categories: Programming

MySQL + SELinux: Can't change dir (Errcode: 13)

If you're using a non-standard MySQL data directory on your Red Hat Enterprise Linux (RHEL) server, you may have seen an error like /usr/libexec/mysqld: Can't change dir to '/mysql_data/' (Errcode: 13). The key to fixing this problem is to ensure the new MySQL data directory has the proper SELinux security context. In my case: # […]

Categories: System Administration