diff options
| author | Tom Christie | 2012-11-19 13:44:53 -0800 |
|---|---|---|
| committer | Tom Christie | 2012-11-19 13:44:53 -0800 |
| commit | cafc00b8e5c87e9d4c6e250d1c77ade728036913 (patch) | |
| tree | 57b9590f5fdcaa603dfa01543499fd5c2858215d /rest_framework/compat.py | |
| parent | ce5b186ca869b693c945200581ba893123a63ce8 (diff) | |
| parent | acc425e74ea305a565d59f517d6e5b83239848a5 (diff) | |
| download | django-rest-framework-cafc00b8e5c87e9d4c6e250d1c77ade728036913.tar.bz2 | |
Merge pull request #424 from jonlil/master
Support for django 1.5a (auth_user_model)
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index e38e7c33..09b76368 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -27,6 +27,20 @@ def get_concrete_model(model_cls): return model_cls +# Django 1.5 add support for custom auth user model +if django.VERSION >= (1, 5): + from django.conf import settings + if hasattr(settings, 'AUTH_USER_MODEL'): + User = settings.AUTH_USER_MODEL + else: + from django.contrib.auth.models import User +else: + try: + from django.contrib.auth.models import User + except ImportError: + raise ImportError(u"User model is not to be found.") + + # First implementation of Django class-based views did not include head method # in base View class - https://code.djangoproject.com/ticket/15668 if django.VERSION >= (1, 4): |
