Skip to content

Commit e4fb3d2

Browse files
committed
Adjust django-guardian check for PY2 compatible version.
1 parent 902223a commit e4fb3d2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rest_framework/compat.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ def is_guardian_installed():
168168
"""
169169
django-guardian is optional and only imported if in INSTALLED_APPS.
170170
"""
171-
if six.PY2:
171+
try:
172+
import guardian
173+
except ImportError:
174+
guardian = None
175+
176+
if six.PY2 and (not guardian or guardian.VERSION >= (1, 5)):
172177
# Guardian 1.5.0, for Django 2.2 is NOT compatible with Python 2.7.
173178
# Remove when dropping PY2.
174179
return False

0 commit comments

Comments
 (0)