From 02e1f69d2b7e7f85f3800a4b11d87b423e726072 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 28 Sep 2015 11:44:07 +0100 Subject: [PATCH] Django 1.9 support --- .travis.yml | 11 +++--- README.md | 4 +-- docs/index.md | 4 +-- rest_framework/utils/field_mapping.py | 8 +++++ tox.ini | 50 +++++++++++++-------------- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index acd711917..e8561a7ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ sudo: false env: - TOX_ENV=py27-lint - TOX_ENV=py27-docs + - TOX_ENV=py35-django19 + - TOX_ENV=py34-django19 + - TOX_ENV=py27-django19 - TOX_ENV=py34-django18 - TOX_ENV=py33-django18 - TOX_ENV=py32-django18 @@ -13,16 +16,12 @@ env: - TOX_ENV=py33-django17 - TOX_ENV=py32-django17 - TOX_ENV=py27-django17 - - TOX_ENV=py27-djangomaster - - TOX_ENV=py34-djangomaster - - TOX_ENV=py35-djangomaster matrix: + # Python 3.5 not yet available on travis, watch this to see when it is. fast_finish: true allow_failures: - - env: TOX_ENV=py27-djangomaster - - env: TOX_ENV=py34-djangomaster - - env: TOX_ENV=py35-djangomaster + - env: TOX_ENV=py35-django19 install: - pip install tox diff --git a/README.md b/README.md index c0b7eab1e..f9bd1f439 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ There is a live example API for testing purposes, [available here][sandbox]. # Requirements -* Python (2.7, 3.2, 3.3, 3.4) -* Django (1.7, 1.8) +* Python (2.7, 3.2, 3.3, 3.4, 3.5) +* Django (1.7, 1.8, 1.9) # Installation diff --git a/docs/index.md b/docs/index.md index 37f192094..4617d0bcc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,8 +52,8 @@ Some reasons you might want to use REST framework: REST framework requires the following: -* Python (2.6.5+, 2.7, 3.2, 3.3, 3.4) -* Django (1.5.6+, 1.6.3+, 1.7+, 1.8) +* Python (2.6.5+, 2.7, 3.2, 3.3, 3.4, 3.5) +* Django (1.7+, 1.8, 1.9) The following packages are optional: diff --git a/rest_framework/utils/field_mapping.py b/rest_framework/utils/field_mapping.py index fef9f5d3d..8206578ee 100644 --- a/rest_framework/utils/field_mapping.py +++ b/rest_framework/utils/field_mapping.py @@ -112,6 +112,14 @@ def get_field_kwargs(field_name, model_field): kwargs['choices'] = model_field.choices return kwargs + # Our decimal validation is handled in the field code, not validator code. + # (In Django 1.9+ this differs from previous style) + if isinstance(model_field, models.DecimalField): + validator_kwarg = [ + validator for validator in validator_kwarg + if not isinstance(validator, validators.DecimalValidator) + ] + # Ensure that max_length is passed explicitly as a keyword arg, # rather than as a validator. max_length = getattr(model_field, 'max_length', None) diff --git a/tox.ini b/tox.ini index 0d3836ff2..0ef64cc49 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ addopts=--tb=short envlist = py27-{lint,docs}, {py27,py32,py33,py34}-django{17,18}, - {py27,py34,py35}-django{master} + {py27,py34,py35}-django{19} [testenv] basepython = @@ -19,17 +19,17 @@ commands = ./runtests.py --fast {posargs} --coverage setenv = PYTHONDONTWRITEBYTECODE=1 deps = - django17: Django==1.7.10 # Should track maximum supported - django18: Django==1.8.4 # Should track maximum supported - djangomaster: https://github.com/django/django/archive/master.tar.gz - -rrequirements/requirements-testing.txt - -rrequirements/requirements-optionals.txt + django17: Django==1.7.10 # Should track maximum supported + django18: Django==1.8.4 # Should track maximum supported + django19: https://www.djangoproject.com/download/1.9a1/tarball/ + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt [testenv:py27-lint] commands = ./runtests.py --lintonly deps = - -rrequirements/requirements-codestyle.txt - -rrequirements/requirements-testing.txt + -rrequirements/requirements-codestyle.txt + -rrequirements/requirements-testing.txt [testenv:py27-docs] commands = mkdocs build @@ -37,24 +37,24 @@ deps = -rrequirements/requirements-testing.txt -rrequirements/requirements-documentation.txt -# Specify explicitly to exclude Django Guardian against Django master (various Pythons) -[testenv:py27-djangomaster] +# Specify explicitly to exclude Django Guardian against Django 1.9 +[testenv:py27-django19] deps = - https://github.com/django/django/archive/master.tar.gz - -rrequirements/requirements-testing.txt - markdown==2.5.2 - django-filter==0.10.0 -[testenv:py34-djangomaster] -deps = - https://github.com/django/django/archive/master.tar.gz - -rrequirements/requirements-testing.txt - markdown==2.5.2 - django-filter==0.10.0 + https://www.djangoproject.com/download/1.9a1/tarball/ + -rrequirements/requirements-testing.txt + markdown==2.5.2 + django-filter==0.10.0 -[testenv:py35-djangomaster] +[testenv:py34-django19] deps = - https://github.com/django/django/archive/master.tar.gz - -rrequirements/requirements-testing.txt - markdown==2.5.2 - django-filter==0.10.0 + https://www.djangoproject.com/download/1.9a1/tarball/ + -rrequirements/requirements-testing.txt + markdown==2.5.2 + django-filter==0.10.0 +[testenv:py35-django19] +deps = + https://www.djangoproject.com/download/1.9a1/tarball/ + -rrequirements/requirements-testing.txt + markdown==2.5.2 + django-filter==0.10.0