Archive for the ‘Programming’ Category
Limit ForeignKey to Staff Users in Django
If you’ve ever built a site that has different kinds of users, you’ve probably run across the case where you want a limited number of users to appear in a particular list. For example, you may only want staff members to be assigned ownership of a particular object. If your site has a really huge [...]
Categories: Programming
No such table: django_admin_log
If you get this error when trying to save something in the Django admin, it’s probably because you forgot to synchronize the database after adding the admin application. If you are using a pre-1.2 version of Django, you can simply:
$ ./managy.py syncdb
Django 1.2 (which is currently in alpha) adds multi-database support. If you want to [...]
Categories: Programming
Convert milliarcseconds to degrees
I was recently working with a GPS device that returned coordinates in milliarcseconds (mas). Unfortunately, not all mapping applications (Google Maps, for example) can understand milliarcseconds. Therefore, I had to convert milliarcseconds to degrees.
The key to the conversion is understanding that one degree is equivalent to 60 arcminutes (arcmin or MOA). Therefore, one degree has [...]
Categories: Programming
Python CSV error on new-line character in unquoted field
I deal with a lot of people that prefer to open reports in Microsoft Excel. I’ve gotten used to generating CSV (comma separated value) files in Python for these folks. Ever so often, someone sends me a CSV file they have created via Excel. Invariably, I will get the following error when trying to read [...]
Categories: Programming
Sorting dictionary keys in Python
For some reason, sorting a dictionary by its keys seems to be one of the most frequently asked Python questions. I’m not sure if this is because it’s just much easier to do in other languages, or if the semantics of the language just confuse new Python developers. I guess the reason for confusion really [...]
Categories: Programming

Get Slaptijack updates delivered to your Inbox or RSS Reader for free!