diff options
| author | Xavier Ordoquy | 2014-07-28 07:37:30 +0200 |
|---|---|---|
| committer | Xavier Ordoquy | 2014-07-28 07:37:30 +0200 |
| commit | fe048dc4fbf064b11d7247061c931bb1038cc774 (patch) | |
| tree | f3dbe948a15b69113e1b1cf53abfe9ea6de11ab3 /rest_framework/compat.py | |
| parent | 299a8347e8ef448eefc611eebfe80d7e142ceaa1 (diff) | |
| download | django-rest-framework-fe048dc4fbf064b11d7247061c931bb1038cc774.tar.bz2 | |
Fix #1712 (issue when django-guardian is installed but not configured/used)
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index fdf12448..9ad8b0d2 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -48,12 +48,15 @@ try: except ImportError: django_filters = None -# guardian is optional -try: - import guardian - import guardian.shortcuts # Fixes #1624 -except ImportError: - guardian = None +# Django-guardian is optional. Import only if guardian is in INSTALLED_APPS +# Fixes (#1712). We keep the try/except for the test suite. +guardian = None +if 'guardian' in settings.INSTALLED_APPS: + try: + import guardian + import guardian.shortcuts # Fixes #1624 + except ImportError: + pass # cStringIO only if it's available, otherwise StringIO |
