Plotly Dash 与 Django 的集成:当前路径 welcome.html 在边栏上应用导航时与其中任何一个都不匹配
Plotly Dash Integration with Django : The current path, welcome.html, didn’t match any of these While Applying Navigation on Sidebar
我关注了this Video Tutorial, and successfully applied all the step and executed. It is working fine. I am now trying to add navigation on the side bar like tables on the bottom of this sidebar navigational menu: but it is giving the following error:
我的师傅urls.py如下:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('home.urls')),
path('django_plotly_dash/', include('django_plotly_dash.urls')),
]
我的申请urls.py是这样的:
from django import urls
from django.urls import path
from . import views
from home.dash_apps.finished_apps import simpleexample
urlpatterns= [
path('', views.home, name='home'),
path('tables/', views.home1, name='home1')
]
而我的sidebar.html如下:
<li class="nav-item">
<a class="nav-link" href="{% url 'home1' %}">
<i class="fas fa-fw fa-table"></i>
<span>Tables</span></a>
</li>
此外,我正在 views.py
中渲染它
def home1(request):
def scatter():
x1 = ['PM2.5','PM10','CO2','NH3']
y1 = [30, 35, 25, 45]
trace = go.Scatter(
x=x1,
y = y1
)
layout = dict(
title='Line Chart: Air Quality Parameters',
xaxis=dict(range=[min(x1), max(x1)]),
yaxis = dict(range=[min(y1), max(y1)])
)
fig = go.Figure(data=[trace], layout=layout)
plot_div = plot(fig, output_type='div', include_plotlyjs=False)
return plot_div
context ={
'plot1': scatter()
}
return render(request, 'home/welcome.html', context)
我无法理解如何正确定位 welcome.html 以便在单击仪表板侧栏中的表格时可以加载它。
url是错误的,需要按照URL定义的url:
path('', views.home, name='home'),
path('tables/', views.home1, name='home1')
尝试:
172.20.43.46.8001/tables/
我关注了this Video Tutorial, and successfully applied all the step and executed. It is working fine. I am now trying to add navigation on the side bar like tables on the bottom of this sidebar navigational menu: but it is giving the following error:
我的师傅urls.py如下:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('home.urls')),
path('django_plotly_dash/', include('django_plotly_dash.urls')),
]
我的申请urls.py是这样的:
from django import urls
from django.urls import path
from . import views
from home.dash_apps.finished_apps import simpleexample
urlpatterns= [
path('', views.home, name='home'),
path('tables/', views.home1, name='home1')
]
而我的sidebar.html如下:
<li class="nav-item">
<a class="nav-link" href="{% url 'home1' %}">
<i class="fas fa-fw fa-table"></i>
<span>Tables</span></a>
</li>
此外,我正在 views.py
中渲染它def home1(request):
def scatter():
x1 = ['PM2.5','PM10','CO2','NH3']
y1 = [30, 35, 25, 45]
trace = go.Scatter(
x=x1,
y = y1
)
layout = dict(
title='Line Chart: Air Quality Parameters',
xaxis=dict(range=[min(x1), max(x1)]),
yaxis = dict(range=[min(y1), max(y1)])
)
fig = go.Figure(data=[trace], layout=layout)
plot_div = plot(fig, output_type='div', include_plotlyjs=False)
return plot_div
context ={
'plot1': scatter()
}
return render(request, 'home/welcome.html', context)
我无法理解如何正确定位 welcome.html 以便在单击仪表板侧栏中的表格时可以加载它。
url是错误的,需要按照URL定义的url:
path('', views.home, name='home'),
path('tables/', views.home1, name='home1')
尝试:
172.20.43.46.8001/tables/