Skip to content

Commit

Permalink
Merge pull request #147 from ticosax/django-2.0-2
Browse files Browse the repository at this point in the history
Bring support for django 2.0 and drf 3.7
  • Loading branch information
auvipy authored Nov 2, 2017
2 parents f19dd14 + ecfb2f6 commit 29b77ce
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ tests/static/
/htmlcov
__pycache__/
*.pyc

.tox/
37 changes: 14 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,20 @@ services:

matrix:
include:
- python: 3.6
env: TOXENV=py36-django111
- python: 3.6
env: TOXENV=py36-django110
- python: 3.6
env: TOXENV=py36-django19
- python: 3.6
env: TOXENV=py36-django18

- python: 3.5
env: TOXENV=py35-django110

- python: 3.4
env: TOXENV=py34-django110

- python: 2.7
env: TOXENV=py27-django111
- python: 2.7
env: TOXENV=py27-django110
- python: 2.7
env: TOXENV=py27-django19
- python: 2.7
env: TOXENV=py27-django18
- env: TOXENV=py27-django111
python: 2.7
- env: TOXENV=py34-django111
python: 3.4
- env: TOXENV=py35-django111
python: 3.5
- env: TOXENV=py36-django111
python: 3.6
- env: TOXENV=py34-django20
python: 3.4
- env: TOXENV=py35-django20
python: 3.5
- env: TOXENV=py36-django20
python: 3.6

branches:
only:
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Compatibility with DRF, Django and Python

=============== ============================ ==================== ==================================
DRF-gis version DRF version Django version Python version
**0.11.x** **3.1** to **3.6** **1.7** to **1.11** **2.7** to **3.6**
**0.12.x** **3.1** to **3.7** **1.9** to **2.0** **2.7** to **3.6**
**0.11.x** **3.1** to **3.7** **1.7** to **1.11** **2.7** to **3.6**
**0.10.x** **3.1** to **3.3** **1.7** to **1.9** **2.7** to **3.5**
**0.9.6** **3.1** to **3.2** **1.5** to **1.8** **2.6** to **3.5**
**0.9.5** **3.1** to **3.2** **1.5** to **1.8** **2.6** to **3.4**
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
six
djangorestframework>=3.3,<3.7
djangorestframework>=3.3,<3.8
4 changes: 2 additions & 2 deletions rest_framework_gis/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict

from django.contrib.gis.geos import GEOSGeometry, GEOSException
from django.contrib.gis.gdal import OGRException
from django.contrib.gis.gdal import GDALException
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from rest_framework.fields import Field, SerializerMethodField
Expand Down Expand Up @@ -38,7 +38,7 @@ def to_internal_value(self, value):
value = json.dumps(value)
try:
return GEOSGeometry(value)
except (ValueError, GEOSException, OGRException, TypeError):
except (ValueError, GEOSException, GDALException, TypeError):
raise ValidationError(_('Invalid format: string or unicode input unrecognized as GeoJSON, WKT EWKT or HEXEWKB.'))

def validate_empty_values(self, data):
Expand Down
19 changes: 12 additions & 7 deletions rest_framework_gis/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
'restframework-gis filters depend on package "django-filter" '
'which is missing. Install with "pip install django-filter".'
)

try: # pragma: no cover
# django >= 1.8
from django.contrib.gis.db.models.lookups import gis_lookups
except ImportError: # pragma: no cover
# django <= 1.7
gis_lookups = models.sql.query.ALL_TERMS
try:
# Django >= 2.0
from django.contrib.gis.db.models.fields import BaseSpatialField
except ImportError:
try: # pragma: no cover
# django >= 1.8,<2.0
from django.contrib.gis.db.models.lookups import gis_lookups
except ImportError: # pragma: no cover
# django <= 1.7
gis_lookups = models.sql.query.ALL_TERMS
else:
gis_lookups = BaseSpatialField.get_lookups()


__all__ = [
Expand Down
1 change: 0 additions & 1 deletion tests/django_restframework_gis_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class BaseModel(models.Model):
slug = models.SlugField(max_length=128, unique=True, blank=True)
timestamp = models.DateTimeField(null=True, blank=True)
geometry = models.GeometryField()
objects = models.GeoManager()

class Meta:
abstract = True
Expand Down
5 changes: 4 additions & 1 deletion tests/django_restframework_gis_tests/test_bbox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import json

from django.test import TestCase
from django.core.urlresolvers import reverse
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured

from rest_framework_gis import serializers as gis_serializers
Expand Down
5 changes: 4 additions & 1 deletion tests/django_restframework_gis_tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from django.conf import settings
from django.test import TestCase
from django.contrib.gis.geos import GEOSGeometry, Polygon
from django.core.urlresolvers import reverse
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse

from .models import Location

Expand Down
5 changes: 4 additions & 1 deletion tests/django_restframework_gis_tests/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
# or by setting ``settings.TEST_PERFORMANCE`` to ``True``
if 'django_restframework_gis_tests.test_performance' in sys.argv or settings.TEST_PERFORMANCE:
from django.test import TestCase
from django.core.urlresolvers import reverse
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from rest_framework.renderers import JSONRenderer
from rest_framework_gis import serializers as gis_serializers
from contexttimer import Timer
Expand Down
5 changes: 4 additions & 1 deletion tests/django_restframework_gis_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from django.test import TestCase
from django.contrib.gis.geos import GEOSGeometry, Polygon, Point
from django.core.urlresolvers import reverse
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured

from rest_framework_gis import serializers as gis_serializers
Expand Down
2 changes: 1 addition & 1 deletion tests/django_restframework_gis_tests/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import generics
from rest_framework.filters import DjangoFilterBackend
from rest_framework_gis.filters import *
from rest_framework_gis.pagination import GeoJsonPagination

Expand Down
7 changes: 5 additions & 2 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from django.conf.urls import include, url
try:
from django.urls import include, url
except ImportError:
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles import views

urlpatterns = [
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[tox]
envlist = py{27,34,35,36,py,py3}-django{18,19,110,111}{,-pytest}
envlist =
py{27,34,35,36,py,py3}-django111{,-pytest}
py{34,35,36,py3}-django20{,-pytest}

[testenv]
usedevelop = true
Expand All @@ -13,10 +15,8 @@ commands =
{env:DRFG_TEST_RUNNER} {posargs:tests/django_restframework_gis_tests}

deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<2.0
django20: Django>=2.0b1,<2.1
-rrequirements-test.txt
pytest: pytest
pytest: pytest-django

0 comments on commit 29b77ce

Please sign in to comment.