问题描述
此处的Django初学者,尝试在我的网页上显示大叶植物地图,但出现此错误:
Django版本==== 3.0.2
此代码:
views.py
from django.shortcuts import render
from .models import Product
from .forms import Productform
# Create your views here.
import folium
from django.views.generic import TemplateView
class foliumView(TemplateView):
template_name = "folium_app/map.html"
def get_context_data(self,**kwargs):
figure = folium.figure()
m = folium.Map(
location=[45.372,-121.6972],zoom_start=12,tiles='Stamen Terrain'
)
m.add_to(figure)
folium.Marker(
location=[45.3288,-121.6625],popup='Mt. Hood Meadows',icon=folium.Icon(icon='cloud')
).add_to(m)
folium.Marker(
location=[45.3311,-121.7113],popup='Timberline Lodge',icon=folium.Icon(color='green')
).add_to(m)
folium.Marker(
location=[45.3300,-121.6823],popup='Some Other Location',icon=folium.Icon(color='red',icon='info-sign')
).add_to(m)
figure.render()
return {"map": figure}
Templates \ folium_map.html
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8">
<title>Title</title>
{{map.header.render|safe}}
</head>
<body>
<div><h1>Here comes my folium map:</h1></div>
{{map.html.render|safe}}
<script>
{{map.script.render|safe}}
</script>
</body>
</html>
如果有人能告诉我如何在显示的地图上做注释,我也将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)