Remove compatibility code for unsupported version of Django.
Switch to an external version of sqlparse.
Modernize exception catching syntax.
Avoid naked except clauses.
Replace print statement by print function.
Enable unicode_literals in all non-empty modules.
Switch from str & unicode to bytes & text.
Replace basestring by six.string_types.
Update imports for renamed modules.
Stopped using dict.iter*.

Since performance isn't a primary concern, the non-iterable versions
will do just fine on Python 2.