Skip to content

Commit 463e60e

Browse files
authored
Add support for Django 3.0 (#231)
* Add six as a dependency Django removed it's embedded six version in Django 3.0, so to support all versions, we need to include it as a dependency. * Add support for Django 3.0 in Creator * Add Python 3.8 and Django 3.0 to tox test matrix * Add Python 3.7 and Python 3.8 to Travis CI setup
1 parent 70a75ab commit 463e60e

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
language: python
55
python:
6+
- 3.8
7+
- 3.7
68
- 3.6
79
- 3.5
810
- 3.4

choicesenum/django/compat.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ def __init__(self, field, model):
1515
self.field = field
1616
if django.VERSION < (2, 1): # pragma: no cover (Django < 2.1 compat)
1717
super(Creator, self).__init__(field.attname, model)
18-
else: # pragma: no cover
18+
elif django.VERSION < (3, 0):
1919
super(Creator, self).__init__(field.attname)
20+
else: # pragma: no cover
21+
super(Creator, self).__init__(field)
2022

2123
def __set__(self, obj, value):
22-
obj.__dict__[self.field_name] = self.field.to_python(value)
24+
if hasattr(self, 'field_name'):
25+
obj.__dict__[self.field_name] = self.field.to_python(value)
26+
else:
27+
obj.__dict__[self.field.attname] = self.field.to_python(value)

choicesenum/django/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
from django.core import checks
66
from django.db import models
77
from django.utils.translation import ugettext_lazy as _
8-
from django.utils import six
98
try:
109
from django.utils.module_loading import import_string
1110
except ImportError: # pragma: no cover, Django 1.6 compat
1211
from django.utils.module_loading import import_by_path as import_string
1312

13+
import six
14+
1415
from .compat import Creator
1516
from ..enums import ChoicesEnum
1617

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
requirements = [
1515
'enum34;python_version<"3.4"',
16+
'six',
1617
]
1718

1819
setup_requirements = []

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
envlist =
33
py{27}-django-{19,110,111}
44
py{34}-django-{110,111,20}
5-
py{35,36,37}-django-{110,111,20,21}
5+
py{35,36,37,38}-django-{110,111,20,21,22}
6+
py{36,37,38}-django-{30}
67
py36-flake8
78

89
[pytest]
@@ -11,6 +12,7 @@ filterwarnings =
1112

1213
[travis]
1314
python =
15+
3.8: py38
1416
3.7: py37
1517
3.6: py36
1618
3.5: py35
@@ -28,11 +30,14 @@ deps =
2830
django-111: Django>=1.11,<1.12
2931
django-20: Django>=2.0,<2.1
3032
django-21: Django>=2.1,<2.2
33+
django-22: Django>=2.2,<2.3
34+
django-30: Django>=3.0,<3.1
3135
commands =
3236
pip install -U pip
3337
py.test --basetemp={envtmpdir} --cov
3438

3539
basepython =
40+
py38: python3.8
3641
py37: python3.7
3742
py36: python3.6
3843
py35: python3.5

0 commit comments

Comments
 (0)