About Map Views

Create a Leaflet map view with the folium package:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import folium
from django.http import HttpResponse

def display_map(request):
    map = folium.Map([52.520833, 13.409444], zoom_start=17)
    folium.Marker(
        location=[52.520833,13.409444],
        tooltip="Click me!",
        popup="TV Tower",
        icon=folium.Icon(icon="blue"),
    ).add_to(map)
    return HttpResponse(map.get_root().render())

Then you can insert that view into any page as an iframe.

Tips and Tricks Programming Development Django 5.x Django 4.2 Django 3.2 Leaflet.js folium