mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Fix #1712 (issue when django-guardian is installed but not configured/used)
This commit is contained in:
parent
299a8347e8
commit
fe048dc4fb
|
@ -48,12 +48,15 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
django_filters = None
|
django_filters = None
|
||||||
|
|
||||||
# guardian is optional
|
# 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:
|
try:
|
||||||
import guardian
|
import guardian
|
||||||
import guardian.shortcuts # Fixes #1624
|
import guardian.shortcuts # Fixes #1624
|
||||||
except ImportError:
|
except ImportError:
|
||||||
guardian = None
|
pass
|
||||||
|
|
||||||
|
|
||||||
# cStringIO only if it's available, otherwise StringIO
|
# cStringIO only if it's available, otherwise StringIO
|
||||||
|
|
Loading…
Reference in New Issue
Block a user