django 2.2.5到目前为止,我在移动 url 时没有遇到问题。报告/reporting.html(索引):...{% url "line_chart_json" %}...报告/views.pyclass LineChartJSONView(BaseLineChartView): def get_labels(self): """Return 7 labels for the x-axis.""" return ["January", "February", "March", "April", "May", "June", "July"] ....当它在主应用程序 url.py 中时,很好from django.urls import path, includefrom reporting.views import LineChartJSONViewurlpatterns = [ ... path('reporting/', include('reporting.urls')), path('line_chart/json/', LineChartJSONView.as_view(), name='line_chart_json'),]当我将其移至报告时from django.urls import pathfrom . import viewsfrom .views import LineChartJSONViewapp_name = 'reporting'urlpatterns = [ path('', views.summary_properties_user, name='index'), path('line_chart/json/', LineChartJSONView.as_view(), name='line_chart_json'),]我在reporting.html上使用它时收到错误消息:NoReverseMatch at /reporting/Reverse for 'line_chart_json' not found. 'line_chart_json' is not a valid view function or pattern name.我假设一个简单的疏忽。仅仅几周后,Django URLs 仍然让我印象深刻。
添加回答
举报
0/150
提交
取消