Fix #1712 (issue when django-guardian is installed but not configured/used)

This commit is contained in:
Xavier Ordoquy 2014-07-28 07:37:30 +02:00
parent 299a8347e8
commit fe048dc4fb

View File

@ -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