View.py
from django.http import HttpResponse
from django.shortcuts import render
from evadata.models import coord2_dj
from django.views.decorators.csrf import csrf_exempt
import json
from django.views.decorators import csrf
from django.http import JsonResponse
import folium
import pandas
from folium import plugins
def getvalue(request):
# ctx = {}
name = str(request.GET.get('gx'))
print(name)
# result_temp = coord2_dj.getmassege(name)
with open('F:/pythonLine/shenzhen.json',encoding = 'utf-8') as f:
san_geo = (json.loads(f.read()))
data2 = read_frame({
'lat': [22.54, 22.59, 22.57,22.53532129],
'lon': [113.95, 113.96, 114.14,114.0513112],
'name': ['sd', 'xl', 'tb','yt'],
'id': [x for x in range(4)]
})
#center
san_map = folium.Map(location=[22.54, 114.05], zoom_start=10,tiles='stamentoner')
#load map
folium.GeoJson(
san_geo,
style_function=lambda feature: {
'fillColor': '#1b1b1b',
'color': 'black',
'weight': 1,
'dashArray': '5, 5',
'fillOpacity': 0.5
}
).add_to(san_map)
return render(request, 'shenzhen_Linemap.html')
在运行manage.py runserver时,出现一个名为“ AttributeError: name ”的错误。但是,当我删除以下几行时,没有错误。
import folium
import pandas
from folium import plugins
我该如何解决该问题以及如何正确导入上述软件包?谢谢。