I transfer the data set from the server:
from django.shortcuts import render .... context.update({ 'request': request, 'model_class' : model_class, 'id': model_class.id, 'coords_x': coords_x, # например, 40.982 (float) 'coords_y': coords_y, # например, 50.982 (float) 'icon': model_icon, # например, "http://image.flaticon.com/icons/svg/126/126482.svg" (unicode) }) return render(request, 'app/mypage.html', context) In app/mypage.html data comes in a strange way. In float numbers, a dot changes to a comma, which is why the script does not perceive it either as a string or as a number, and gives an error not only when trying to process data, but also when converting to float or string . This problem can be circumvented by passing in the context not coords_x , but str(coords_x) , then the point will be preserved and it will be possible to convert this to a number on the client. But it looks weird. And I can not solve the problem with model_icon : the browser does not accept the url string after the colon. Uncaught SyntaxError: Unexpected token : Even if the colon is removed from the transmitted string, the same error occurs. What you need to read to figure out why this is happening?
A non-working piece from app/mypage.html :
<div class='item_map'> {% leaflet_map "map" callback='map_init_point' %} </div> <script type="text/javascript"> 'use strict'; function map_init_point (map, options){ var coords = []; coords.push(parseFloat({{ coords_x }})); coords.push(parseFloat({{ coords_y }})); if ({{ icon|safe }}){ // вот эта строка никак не хочет работать // в консоли браузера она выглядит как // if (image.flaticon.com/icons/svg/46/46045.svg){ , // а переменная должна быть в кавычках var Point_Icon = L.icon({ iconUrl: 'http://' + {{ icon|safe }}, iconSize: [20, 20], iconAnchor: [10, 10], }); L.marker(coords, {icon: Point_Icon}).addTo(map); } else { L.marker(coords).addTo(map); } map.setView({{ center }}, {{ zoom }}-3); setTimeout(function(){ window.print(); }, 2000); };