summaryrefslogtreecommitdiff
path: root/django/contrib/gis/forms
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2022-08-12 12:18:51 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-08-12 13:26:35 +0200
commit4fcba800b84fc5fb53cdc70e4bea37ec958516fd (patch)
tree4ca13bb1947503e1a1202a0513deda760bc8090e /django/contrib/gis/forms
parent8c3046daade8d9b019928f96e53629b03060fe73 (diff)
Fixed #33924 -- Deprecated BaseGeometryWidget.map_height/map_width attributes.
Diffstat (limited to 'django/contrib/gis/forms')
-rw-r--r--django/contrib/gis/forms/widgets.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py
index 0f53ee2e96..5f169e9cb3 100644
--- a/django/contrib/gis/forms/widgets.py
+++ b/django/contrib/gis/forms/widgets.py
@@ -1,4 +1,5 @@
import logging
+import warnings
from django.conf import settings
from django.contrib.gis import gdal
@@ -6,6 +7,7 @@ from django.contrib.gis.geometry import json_regex
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Widget
from django.utils import translation
+from django.utils.deprecation import RemovedInDjango51Warning
logger = logging.getLogger("django.contrib.gis")
@@ -18,8 +20,8 @@ class BaseGeometryWidget(Widget):
geom_type = "GEOMETRY"
map_srid = 4326
- map_width = 600
- map_height = 400
+ map_width = 600 # RemovedInDjango51Warning
+ map_height = 400 # RemovedInDjango51Warning
display_raw = False
supports_3d = False
@@ -29,6 +31,17 @@ class BaseGeometryWidget(Widget):
self.attrs = {}
for key in ("geom_type", "map_srid", "map_width", "map_height", "display_raw"):
self.attrs[key] = getattr(self, key)
+ if (
+ (attrs and ("map_width" in attrs or "map_height" in attrs))
+ or self.map_width != 600
+ or self.map_height != 400
+ ):
+ warnings.warn(
+ "The map_height and map_width widget attributes are deprecated. Please "
+ "use CSS to size map widgets.",
+ category=RemovedInDjango51Warning,
+ stacklevel=2,
+ )
if attrs:
self.attrs.update(attrs)