我试图在主页上添加到blogDetails.html
的链接,但是使用{% url '...' %}
模板标记引发了一个反向未找到异常。你知道吗
索引.html
<a href="{% url 'blogDetails' %}">O blogu</a>
网址.py
path('blogDetails/', views.BlogDetailsPageView.as_view(), name='blogDetails'),
视图.py
class BlogDetailsPageView(TemplateView):
template_name = 'blog/blogDetails.html'
主网址.py
urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('blog.urls', namespace='blog')),
]
这是我得到的错误:
Reverse for 'blogDetails' not found. 'blogDetails' is not a valid view function or pattern name.
这到底是怎么回事?感谢大家的帮助。你知道吗
在} template tag ,它说:
urlpatterns
中使用namespace='blog'
。看看the django documentation for the ^{如果将blog名称空间添加到templatetag调用中,它应该可以工作:
相关问题 更多 >
编程相关推荐