这个问题一般怎么解决呢
urls.py
urlpatterns = [
#主页
url(r'^$',views.index, name='index'),
# 音乐类别总占比饼状图
url(r'^$',views.music_category,name = 'music_category' ),
#每年歌曲发布数量折线图
url(r'^$',views.publishsongs,name = 'publishsongs' ),
#top10歌手平均分柱状图
url(r'^$',views.top10_singers,name = 'top10_singers' )
]
from django.shortcuts import render,HttpResponse
#跳转到主页
def index(request):
return render(request,'index.html')
def music_category(request):
return render(request,'music_category.html')
#跳转到每年歌曲发布数量折线图
def publishsongs(request):
return render(request,'publishsongs.html')
#跳转到top10歌手平均分柱状图
def top10_singers(request):
return render(request,'top10_singers.html')
你django学了几天???
路由的关键字是url,不是path,我猜你学的是很老的django版本吧
问题在于所有的视图都用的一个路由地址,
但我不会用url,我只会path
urlpatterns =【
# 主页
path("",views.index, name='index'),
# 音乐类别总占比饼状图
path("/http://127.0.0.1/",views.music_category,name = 'music_category'),
】
最后浏览器地址是
http://127.0.0.1/music_category/