Locu/djoauth2 — pull request #9 by peterldowns (2014-04-04 18:58:35+00:00)
Title: Add support for custom User models.

Django 1.5+ supports a configurable User model, instead of forcing developers to use `django.contrib.auth.models.User`. Until now, `djoauth2` has explicitly linked to `django.contrib.auth.models.User`, which means that developers with custom User models could not use this library.

This diffset:
* Updates the `djoauth2` models to look for the configured User model, not just `django.contrib.auth.models.User`.
* Updates the existing migration file (`0001_initial.py`) to use the configured User model in Django 1.5+, while still remaining equivalent to the previous version when used in Django 1.4.
* Updates the `generate_migrations.py` script to automatically refactor any generated migrations to maintain this compatibility, instead of forcing developers to do this by hand. Big thanks to @Benjaoming for [the original version of the refactoring script](https://gist.github.com/benjaoming/5605160), which I've updated slightly in order to make it easier to call from other Python code.
* Fixes a bug where the production (not development) requirements were being installed in the development virtual env created by `make dev-env`.

This diffset *does not* contain any tests because I'm not sure how to test this sort of migration change. Using the example application locally I've been able to verify that the code works as I expect, but it would be great to do this in an automated way. Contributions welcome!

One other thing to know: this change *will break* `djoauth2` for developers with custom user models who previously installed `djoauth2`. Their databases have been migrated such that the `djoauth2` models point to `django.contrib.auth.models.User`, but this diff changes the migration to point to their configurable model. I suspect that no users are in this situation but at the same time I want to make it known that this could be an issue.