diff options
| author | Jonas Liljestrand | 2012-11-17 20:35:15 +0100 |
|---|---|---|
| committer | Jonas Liljestrand | 2012-11-17 20:35:15 +0100 |
| commit | 8eb4bb8090a84282c3537641e8ecb5c38a33fc41 (patch) | |
| tree | 3509516f388c5541313669a04cd560d7039d7deb /rest_framework/compat.py | |
| parent | cd482c0ad22bbb810378c61e02a790e5e3796aa7 (diff) | |
| download | django-rest-framework-8eb4bb8090a84282c3537641e8ecb5c38a33fc41.tar.bz2 | |
Moved function for getting correct user model to compat.py
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..d5ad2a7a 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.db.models.auth import User + except ImportError: + raise ImportError('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): |
