Skip to content

Commit

Permalink
Adjust django-guardian check for PY2 compatible version. (encode#6613)
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson authored and Pierre Chiquet committed Mar 24, 2020
1 parent 53189c1 commit 3d4afdc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rest_framework/compat.py
Expand Up @@ -168,7 +168,12 @@ def is_guardian_installed():
"""
django-guardian is optional and only imported if in INSTALLED_APPS.
"""
if six.PY2:
try:
import guardian
except ImportError:
guardian = None

if six.PY2 and (not guardian or guardian.VERSION >= (1, 5)):
# Guardian 1.5.0, for Django 2.2 is NOT compatible with Python 2.7.
# Remove when dropping PY2.
return False
Expand Down

0 comments on commit 3d4afdc

Please sign in to comment.