Support for Django 1.5 custom user models

Uses get_user_model for every reference to User, and provides a default
implementation of get_user_model for Django <= 1.4
Fix some missing imports and settings import errors for the new user model hooks.
Merge