diff --git a/leaflet/forms/widgets.py b/leaflet/forms/widgets.py index ae0624e..cf29a14 100644 --- a/leaflet/forms/widgets.py +++ b/leaflet/forms/widgets.py @@ -93,6 +93,9 @@ def get_context(self, name, value, attrs): value = None if value in validators.EMPTY_VALUES else value context = super().get_context(name, value, attrs) context.update(self.get_attrs(name, attrs)) + # The next 2 lines can be removed once Django 5.2 support is dropped. + if "geom_name" not in context["widget"]["attrs"]: + context["widget"]["attrs"]["geom_name"] = context["geom_type"] context["csp_nonce"] = self.csp_nonce context["FORCE_IMAGE_PATH"] = static("leaflet/images/") if app_settings['FORCE_IMAGE_PATH'] else False context["reset_view_icon"] = static("leaflet/images/reset-view.png") diff --git a/leaflet/templates/leaflet/widget.html b/leaflet/templates/leaflet/widget.html index 3dce00e..ac259a2 100644 --- a/leaflet/templates/leaflet/widget.html +++ b/leaflet/templates/leaflet/widget.html @@ -15,8 +15,8 @@ {% block vars %}var {{ module }} = {}; {{ module }}.fieldid = '{{ id_css }}'; {{ module }}.modifiable = {{ modifiable|yesno:"true,false" }}; - {{ module }}.geom_type = '{{ geom_type }}'; - {{ module }}.srid = {{ map_srid|unlocalize }}; + {{ module }}.geom_type = '{{ widget.attrs.geom_name }}'; + {{ module }}.srid = {{ widget.attrs.map_srid|unlocalize }}; {% endblock vars %} function {{ id_map_callback }}(map, options) {