Skip to content

Commit baf412b

Browse files
authored
Add support for Django 6 (#398)
1 parent 32fadf5 commit baf412b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

leaflet/forms/widgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def get_context(self, name, value, attrs):
9393
value = None if value in validators.EMPTY_VALUES else value
9494
context = super().get_context(name, value, attrs)
9595
context.update(self.get_attrs(name, attrs))
96+
# The next 2 lines can be removed once Django 5.2 support is dropped.
97+
if "geom_name" not in context["widget"]["attrs"]:
98+
context["widget"]["attrs"]["geom_name"] = context["geom_type"]
9699
context["csp_nonce"] = self.csp_nonce
97100
context["FORCE_IMAGE_PATH"] = static("leaflet/images/") if app_settings['FORCE_IMAGE_PATH'] else False
98101
context["reset_view_icon"] = static("leaflet/images/reset-view.png")

leaflet/templates/leaflet/widget.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
{% block vars %}var {{ module }} = {};
1616
{{ module }}.fieldid = '{{ id_css }}';
1717
{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};
18-
{{ module }}.geom_type = '{{ geom_type }}';
19-
{{ module }}.srid = {{ map_srid|unlocalize }};
18+
{{ module }}.geom_type = '{{ widget.attrs.geom_name }}';
19+
{{ module }}.srid = {{ widget.attrs.map_srid|unlocalize }};
2020
{% endblock vars %}
2121

2222
function {{ id_map_callback }}(map, options) {

0 commit comments

Comments
 (0)