Skip to content

Commit c46de7e

Browse files
committed
[cleanup] Remove compatibility code for unsupported DRF versions
1 parent 8c2390c commit c46de7e

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

rest_framework_gis/apps.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ def ready(self):
1313

1414
from .fields import GeometryField
1515

16-
try:
17-
# drf 3.0
18-
field_mapping = ModelSerializer._field_mapping.mapping
19-
except AttributeError:
20-
# drf 3.1
21-
field_mapping = ModelSerializer.serializer_field_mapping
16+
field_mapping = ModelSerializer.serializer_field_mapping
2217

2318
# map GeoDjango fields to drf-gis GeometryField
2419
field_mapping.update(

tests/django_restframework_gis_tests/tests.py

-13
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from .models import LocatedFile, Location, Nullable
1919
from .serializers import LocationGeoSerializer
2020

21-
is_pre_drf_39 = not rest_framework.VERSION.startswith('3.9')
22-
2321

2422
class TestRestFrameworkGis(TestCase):
2523
def setUp(self):
@@ -526,7 +524,6 @@ def test_post_geojson_location_list_HTML_web_form_WKT(self):
526524
location = Location.objects.all()[0]
527525
self.assertEqual(location.name, "HTML test WKT")
528526

529-
@skipIf(is_pre_drf_39, 'Skip this test if DRF < 3.9')
530527
def test_geojson_HTML_widget_value(self):
531528
self._create_locations()
532529
response = self.client.get(
@@ -536,16 +533,6 @@ def test_geojson_HTML_widget_value(self):
536533
self.assertContains(response, '"type": "Point"')
537534
self.assertContains(response, '"coordinates": [')
538535

539-
@skipIf(not is_pre_drf_39, 'Skip this test if DRF >= 3.9')
540-
def test_geojson_HTML_widget_value_pre_drf_39(self):
541-
self._create_locations()
542-
response = self.client.get(
543-
self.geojson_location_list_url, headers={"accept": 'text/html'}
544-
)
545-
self.assertContains(response, '<textarea name="geometry"')
546-
self.assertContains(response, '&quot;type&quot;: &quot;Point&quot;')
547-
self.assertContains(response, '&quot;coordinates&quot;: [')
548-
549536
def test_patch_geojson_location(self):
550537
location = Location.objects.create(
551538
name='geojson patch test', geometry='POINT (135.0 45.0)'

0 commit comments

Comments
 (0)