Using the django-leaflet plugin, I display a map on a form. To do this, you need to install the plugin, add it to INSTALLED_APPS and add the LEAFLET_CONFIG variable with the tiles to settings. Tiles I can load as follows:
'TILES': 'http://{s}.tile.osm.org/{z}/{x}/{y}.png', As far as is clear from the documentation, the server part is over. Next, in the html file, add {% load leaflet_tags %} to the header and add the head section
{% leaflet_js %} {% leaflet_css %} and in the body - the string
{% leaflet_map "map" callback='map_init' %} and script:
<script type='text/javascript'> function map_init (map, options){ L.marker(47.79470655664555, 39.13330078125).addTo(map); } </script> And the map is displayed. But there are two problems: if you set the tile not in settings, but in the script with the code L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map); as specified in the documentation, the tiles are not loaded. And the second problem: even if you describe tiles in settings, when I print a map, instead of a map, I have an empty Leaflet window - without a substrate.
I print the page by code
<script> 'use strict'; window.print(); </script> in the same template.
PS SetTimeOut solves the second problem.