Merge pull request #74 from jar3b/django-30-support

Django 3.0 support
This commit is contained in:
Swen Kooij 2020-01-06 16:44:59 +01:00 committed by GitHub
commit 53d7cd0c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View File

@ -20,7 +20,7 @@ jobs:
- run:
name: Run tests
command: tox -e 'py37-dj{20,21,22}'
command: tox -e 'py37-dj{20,21,22,30}'
environment:
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
@ -47,7 +47,7 @@ jobs:
- run:
name: Run tests
command: tox -e 'py38-dj{20,21,22}'
command: tox -e 'py38-dj{20,21,22,30}'
environment:
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'

View File

@ -3,7 +3,7 @@
| :white_check_mark: | **Tests** | [![CircleCI](https://circleci.com/gh/SectorLabs/django-localized-fields/tree/master.svg?style=svg)](https://circleci.com/gh/SectorLabs/django-localized-fields/tree/master) |
| :memo: | **License** | [![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org) |
| :package: | **PyPi** | [![PyPi](https://badge.fury.io/py/django-localized-fields.svg)](https://pypi.python.org/pypi/django-localized-fields) |
| <img src="https://icon-library.net/images/django-icon/django-icon-0.jpg" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2 |
| <img src="https://icon-library.net/images/django-icon/django-icon-0.jpg" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0 |
| <img src="http://www.iconarchive.com/download/i73027/cornmanthe3rd/plex/Other-python.ico" width="22px" height="22px" align="center" /> | **Python Versions** | 3.7, 3.8 |
| :book: | **Documentation** | [Read The Docs](https://django-localized-fields.readthedocs.io) |
| :warning: | **Upgrade** | [Upgrade fom v5.x](https://django-localized-fields.readthedocs.io/en/latest/releases.html#v6-0)

View File

@ -1,5 +1,5 @@
from django.conf import settings
from django.utils import six, translation
from django.utils import translation
class LocalizedValueDescriptor:
@ -57,7 +57,7 @@ class LocalizedValueDescriptor:
return instance.__dict__[self.field.name]
def __set__(self, instance, value):
if isinstance(value, six.string_types):
if isinstance(value, str):
language = translation.get_language() or settings.LANGUAGE_CODE
self.__get__(instance).set(
language, value

View File

@ -5,7 +5,6 @@ import posixpath
from django.core.files import File
from django.core.files.storage import default_storage
from django.db.models.fields.files import FieldFile
from django.utils import six
from django.utils.encoding import force_str, force_text
from localized_fields.fields import LocalizedField
@ -56,7 +55,7 @@ class LocalizedFileValueDescriptor(LocalizedValueDescriptor):
def __get__(self, instance, cls=None):
value = super().__get__(instance, cls)
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)
value.set(lang, file)
@ -120,7 +119,7 @@ class LocalizedFileField(LocalizedField):
else:
# Need to convert File objects provided via a form to
# 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(value)

View File

@ -1,11 +1,12 @@
[tox]
envlist = py37-dj{20,21,22}, py38-dj{20,21,22}
envlist = py37-dj{20,21,22,30}, py38-dj{20,21,22,30}
[testenv]
deps =
dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2
dj22: Django>=2.2,<2.3
dj30: Django>=3.0a1,<3.1
-rrequirements/test.txt
setenv =
DJANGO_SETTINGS_MODULE=settings