【发布时间】:2019-02-22 14:37:22
【问题描述】:
我正在尝试从列表模板访问详细模板
示例:
文章:网址
article_patterns = [
path('', HomePageView.as_view(), name='home')
path('articles/', ArticleListView.as_view(), name="articles"),
path('articles/<int:pk>/', ArticleDetailView.as_view(), name="article"),
]
主要网址
urlpatterns = [
path('', include(article_patterns)),
path('admin/', admin.site.urls),
]
在article_list.html
<a href="{% url 'articles:article' article.id %}"> Detail {{articles.title}}</a>
但我有这个错误:articles is not a registered namespace
有什么想法或建议吗?
【问题讨论】:
-
请提供所有 urls.py 代码
-
只使用
{% url 'article' article.id %}而不使用articles:命名空间。 -
因为里面有类似 app_name 的东西
-
谢谢@floydya 它运作良好
标签: django django-templates python-3.6 django-2.0