Skip to content

Commit a1362f4

Browse files
Merge pull request denisorehovsky#2 from Jorl17/master
Make project Python2 compatible
2 parents 112b10c + b878852 commit a1362f4

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ cache: pip
55
matrix:
66
fast_finish: true
77
include:
8+
- python: 2.7
9+
env: TOXENV=py27-django111-drf37
10+
811
- python: 3.4
912
env: TOXENV=py34-django111-drf37
1013
- python: 3.4

rest_polymorphic/serializers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import Mapping
2+
from six import string_types
23

34
from django.core.exceptions import ImproperlyConfigured
45
from django.db import models
@@ -17,16 +18,16 @@ def __new__(cls, *args, **kwargs):
1718
cls=cls.__name__
1819
)
1920
)
20-
if not isinstance(cls.resource_type_field_name, str):
21+
if not isinstance(cls.resource_type_field_name, string_types):
2122
raise ImproperlyConfigured(
2223
'`{cls}.resource_type_field_name` must be a string'.format(
2324
cls=cls.__name__
2425
)
2526
)
26-
return super().__new__(cls, *args, **kwargs)
27+
return super(PolymorphicSerializer, cls).__new__(cls, *args, **kwargs)
2728

2829
def __init__(self, *args, **kwargs):
29-
super().__init__(*args, **kwargs)
30+
super(PolymorphicSerializer, self).__init__(*args, **kwargs)
3031

3132
model_serializer_mapping = self.model_serializer_mapping
3233
self.model_serializer_mapping = {}

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def run(self):
7171
'django',
7272
'djangorestframework',
7373
'django-polymorphic',
74+
'six',
7475
],
7576
classifiers=[
7677
# Trove classifiers

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tox]
22
envlist =
3+
py27-django111-drf37
34
{py34,py35,py36,py37}-django{111,20}-drf37,
45
py{35,36,37}-djangomaster-drf37
56
flake8
@@ -8,6 +9,7 @@ envlist =
89
[testenv]
910
passenv = CI TRAVIS TRAVIS_*
1011
basepython =
12+
py27: python2.7
1113
py34: python3.4
1214
py35: python3.5
1315
py36: python3.6

0 commit comments

Comments
 (0)