mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-24 19:32:53 +03:00
fix: remove django.utils.six import and usage due to Django 3.0 dropped support for it
This commit is contained in:
parent
e5ea632f24
commit
769066a461
@ -1,5 +1,5 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import six, translation
|
from django.utils import translation
|
||||||
|
|
||||||
|
|
||||||
class LocalizedValueDescriptor:
|
class LocalizedValueDescriptor:
|
||||||
@ -57,7 +57,7 @@ class LocalizedValueDescriptor:
|
|||||||
return instance.__dict__[self.field.name]
|
return instance.__dict__[self.field.name]
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
language = translation.get_language() or settings.LANGUAGE_CODE
|
language = translation.get_language() or settings.LANGUAGE_CODE
|
||||||
self.__get__(instance).set(
|
self.__get__(instance).set(
|
||||||
language, value
|
language, value
|
||||||
|
@ -5,7 +5,6 @@ import posixpath
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
from django.db.models.fields.files import FieldFile
|
from django.db.models.fields.files import FieldFile
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import force_str, force_text
|
from django.utils.encoding import force_str, force_text
|
||||||
|
|
||||||
from localized_fields.fields import LocalizedField
|
from localized_fields.fields import LocalizedField
|
||||||
@ -56,7 +55,7 @@ class LocalizedFileValueDescriptor(LocalizedValueDescriptor):
|
|||||||
def __get__(self, instance, cls=None):
|
def __get__(self, instance, cls=None):
|
||||||
value = super().__get__(instance, cls)
|
value = super().__get__(instance, cls)
|
||||||
for lang, file in value.__dict__.items():
|
for lang, file in value.__dict__.items():
|
||||||
if isinstance(file, six.string_types) or file is None:
|
if isinstance(file, str) or file is None:
|
||||||
file = self.field.value_class(instance, self.field, file, lang)
|
file = self.field.value_class(instance, self.field, file, lang)
|
||||||
value.set(lang, file)
|
value.set(lang, file)
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ class LocalizedFileField(LocalizedField):
|
|||||||
else:
|
else:
|
||||||
# Need to convert File objects provided via a form to
|
# Need to convert File objects provided via a form to
|
||||||
# unicode for database insertion
|
# unicode for database insertion
|
||||||
prep_value.set(k, six.text_type(v))
|
prep_value.set(k, str(v))
|
||||||
return super().get_prep_value(prep_value)
|
return super().get_prep_value(prep_value)
|
||||||
return super().get_prep_value(value)
|
return super().get_prep_value(value)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user