Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions leaflet/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions leaflet/templates/leaflet/widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down