Django has a nice serializer library for models, but for a simple way of dumping primitive types straight out to JSON would be to use json.
If you try to use Django's serializer on primitives you'll get this error:
AttributeError: 'str' object has no attribute '_meta'
Instead, use Python's built in library support.
Python 2.5 has "simplejson", so to make sure you import the right one, just use this import statement.
import simplejson as json
[ Source ]