aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorStephan Groß2012-11-21 11:56:34 +0100
committerStephan Groß2012-11-21 11:56:34 +0100
commit6ba4df8a27016fd5e60a3852eea6c97231a03281 (patch)
tree935bb3d51a9c3f4307d2d83d4b4c2e4d884886e3 /rest_framework/compat.py
parented713d0354b67bdc64de9346b9a72e1adfced76e (diff)
parent3268c67343f6fc6364a0127a7bfabeb907a4751d (diff)
downloaddjango-rest-framework-6ba4df8a27016fd5e60a3852eea6c97231a03281.tar.bz2
Merge remote-tracking branch 'upstream/master' into regex_field
Conflicts: docs/topics/release-notes.md
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index 5055bfd3..09b76368 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -1,6 +1,6 @@
"""
The `compat` module provides support for backwards compatibility with older
-versions of django/python, and compatbility wrappers around optional packages.
+versions of django/python, and compatibility wrappers around optional packages.
"""
# flake8: noqa
import django
@@ -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):