mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-10-29 18:18:57 +03:00
Python 3.6, 3.9 and Django 3.0 compatibility
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user