diff options
| author | Tom Christie | 2014-08-19 10:11:10 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-08-19 10:11:10 +0100 | 
| commit | e385a7b8eb6e538698f28128e43fe8bfaefd4e97 (patch) | |
| tree | 3f1cac50c40ec77a0bc5537f1a04628901a4d2ce /rest_framework/compat.py | |
| parent | 2aad8e4b35c3552a065347d7eccad8bd51938783 (diff) | |
| parent | 48b66ec2a2b744f170034adbdaaa1588e6c14e11 (diff) | |
| download | django-rest-framework-e385a7b8eb6e538698f28128e43fe8bfaefd4e97.tar.bz2 | |
Merge master
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 6a5cbbe4..4b16a8ca 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -44,12 +44,15 @@ except ImportError:      django_filters = None -# django-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 | 
