Made migrations compatible with custom user models in Django 1.5+.

Allows the migrations to run when custom user models are used in the project. Backwards-compatible with pre-1.5 Django.