Python 3.6, 3.9 and Django 3.0 compatibility

This commit is contained in:
Swen Kooij
2020-01-06 15:46:40 +01:00
parent 53d7cd0c66
commit 49d88af76a
11 changed files with 120 additions and 46 deletions

View File

@@ -1,7 +1,4 @@
import bleach
from django.conf import settings
from django_bleach.utils import get_bleach_default_options
from .field import LocalizedField
@@ -22,6 +19,20 @@ class LocalizedBleachField(LocalizedField):
to the database or an update.
"""
# the bleach library vendors dependencies and the html5lib
# dependency is incompatible with python 3.9, until that's
# fixed, you cannot use LocalizedBleachField with python 3.9
# sympton:
# ImportError: cannot import name 'Mapping' from 'collections'
try:
import bleach
from django_bleach.utils import get_bleach_default_options
except ImportError:
raise UserWarning(
"LocalizedBleachField is not compatible with Python 3.9 yet."
)
localized_value = getattr(instance, self.attname)
if not localized_value:
return None