我遵循了这个视频教程,成功地应用了所有步骤并执行了。它工作得很好。我现在尝试在侧栏导航菜单底部的侧栏上添加导航,类似于表格:但出现以下错误:
我的主URL.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')),
]
我的应用程序URL.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')
]
而my 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,以便在单击 Jmeter 板侧栏中的表格时加载它。
1条答案
按热度按时间q9rjltbz1#
url错误,您需要遵循url定义的url:
尝试: