1π
β
In order to use venue.name
in the HTML string, you can use str.format()
to insert the venue.name
variable into the popup content, like so:
def index(request):
venue_markers = Venue.objects.all()
m = folium.Map(location=center_location,zoom_start=center_zoom_start,tiles=tiles_style)
for venue in venue_markers:
html = """
<!DOCTYPE html>
<html>
<body>
<h1>{}</h1>
</body>
</html>
""".format(venue.name)
iframe = branca.element.IFrame(html=html, width=150, height=75)
popup=folium.Popup(iframe, max_width=2650)
coordinates =(venue.latitude, venue.longitude)
folium.Marker(coordinates,popup=popup,icon=folium.Icon(color='black',icon='utensils',prefix='fa',fill_opacity=1)).add_to(m)
context = {'venue_markers':venue_markers,'map':m._repr_html_}
return render(request,'main/index.html',context)
π€Sunderam Dubey
Source:stackexchange.com