Skip to content

Commit

Permalink
Fix warning on Django 3.1
Browse files Browse the repository at this point in the history
Fix this warning raised from Django 3.1 onwards:

```
venv/lib/python3.8/site-packages/djgeojson/fields.py:60
  /.../venv/lib/python3.8/site-packages/djgeojson/fields.py:60: RemovedInDjango40Warning: django.utils.translation.ugettext_lazy() is deprecated in favor of django.utils.translation.gettext_lazy().
    description = _("Geometry as GeoJSON")
```

Also add Django 3.1 to the travis definition.
  • Loading branch information
adamchainz committed Oct 8, 2020
1 parent c05b17c commit 9f521fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Expand Up @@ -27,6 +27,7 @@ env:
- DJANGO_VERSION=2.1.15
- DJANGO_VERSION=2.2.10
- DJANGO_VERSION=3.0.3
- DJANGO_VERSION=3.1.2

install:
# This is a dependency of our Django test script
Expand All @@ -53,8 +54,12 @@ matrix:
env: DJANGO_VERSION=2.2.10
- python: 3.4
env: DJANGO_VERSION=3.0.3
- python: 3.4
env: DJANGO_VERSION=3.1.2
- python: 3.5
env: DJANGO_VERSION=3.0.3
- python: 3.5
env: DJANGO_VERSION=3.1.2
- python: 3.8
env: DJANGO_VERSION=2.0.13
- python: 3.8
Expand Down
8 changes: 7 additions & 1 deletion djgeojson/fields.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals

import django
from django.forms.widgets import HiddenInput
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import (ValidationError,
ImproperlyConfigured)
try:
Expand All @@ -22,6 +22,12 @@ def __init__(self, *args, **kwargs):
JSONFormField = Missing


if django.VERSION >= (3, 1):
from django.utils.translation import gettext_lazy as _
else:
from django.utils.translation import ugettext_lazy as _


class GeoJSONValidator(object):
def __init__(self, geom_type):
self.geom_type = geom_type
Expand Down

0 comments on commit 9f521fb

Please sign in to comment.