summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-22 11:36:27 +0200
committerGitHub <noreply@github.com>2022-04-22 11:36:27 +0200
commiteeb0bb63795f7500156abaed2a94aae681a9fc4a (patch)
tree71535b36835e3eee72253a22b3dcad62ba223220
parent6f453cd2981525b33925faaadc7a6e51fa90df5c (diff)
Refs #27674 --- Deprecated django.contrib.gis.admin.OpenLayersWidget.
-rw-r--r--django/contrib/gis/admin/__init__.py2
-rw-r--r--django/contrib/gis/admin/widgets.py11
-rw-r--r--docs/internals/deprecation.txt2
-rw-r--r--docs/releases/4.1.txt2
-rw-r--r--tests/gis_tests/geoadmin_deprecated/tests.py5
5 files changed, 21 insertions, 1 deletions
diff --git a/django/contrib/gis/admin/__init__.py b/django/contrib/gis/admin/__init__.py
index d5bd54c479..2c3de6f4c5 100644
--- a/django/contrib/gis/admin/__init__.py
+++ b/django/contrib/gis/admin/__init__.py
@@ -27,8 +27,8 @@ __all__ = [
"register",
"site",
"GISModelAdmin",
- "OpenLayersWidget",
# RemovedInDjango50Warning.
"GeoModelAdmin",
+ "OpenLayersWidget",
"OSMGeoAdmin",
]
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
index 420c170608..9ba262aaf8 100644
--- a/django/contrib/gis/admin/widgets.py
+++ b/django/contrib/gis/admin/widgets.py
@@ -1,9 +1,12 @@
+# RemovedInDjango50Warning.
import logging
+import warnings
from django.contrib.gis.gdal import GDALException
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Textarea
from django.utils import translation
+from django.utils.deprecation import RemovedInDjango50Warning
# Creating a template context that contains Django settings
# values needed by admin map templates.
@@ -16,6 +19,14 @@ class OpenLayersWidget(Textarea):
Render an OpenLayers map using the WKT of the geometry.
"""
+ def __init__(self, *args, **kwargs):
+ warnings.warn(
+ "django.contrib.gis.admin.OpenLayersWidget is deprecated.",
+ RemovedInDjango50Warning,
+ stacklevel=2,
+ )
+ super().__init__(*args, **kwargs)
+
def get_context(self, name, value, attrs):
# Update the template parameters with any attributes passed in.
if attrs:
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index eb6d7f7b2f..903f2f7161 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -101,6 +101,8 @@ details on these changes.
``SimpleTestCase.assertFormError()`` and ``assertFormsetError()`` will no
longer be allowed.
+* The ``django.contrib.gis.admin.OpenLayersWidget`` will be removed.
+
.. _deprecation-removed-in-4.1:
4.1
diff --git a/docs/releases/4.1.txt b/docs/releases/4.1.txt
index 2c01efbfdd..0de527447b 100644
--- a/docs/releases/4.1.txt
+++ b/docs/releases/4.1.txt
@@ -610,6 +610,8 @@ Miscellaneous
or pass the form/formset object directly instead.
+* The undocumented ``django.contrib.gis.admin.OpenLayersWidget`` is deprecated.
+
Features removed in 4.1
=======================
diff --git a/tests/gis_tests/geoadmin_deprecated/tests.py b/tests/gis_tests/geoadmin_deprecated/tests.py
index dd3e3af069..d6bea7a690 100644
--- a/tests/gis_tests/geoadmin_deprecated/tests.py
+++ b/tests/gis_tests/geoadmin_deprecated/tests.py
@@ -125,3 +125,8 @@ class DeprecationTests(SimpleTestCase):
DeprecatedOSMGeoAdmin(City, site)
with self.assertRaisesMessage(RemovedInDjango50Warning, msg):
DeprecatedGeoModelAdmin(City, site)
+
+ def test_openlayerswidget_warning(self):
+ msg = "django.contrib.gis.admin.OpenLayersWidget is deprecated."
+ with self.assertRaisesMessage(RemovedInDjango50Warning, msg):
+ admin.OpenLayersWidget()