Port to Django 1.6

This obviously needs some refinement but all but one or two tests pass at this stage, so your comments are solicited.