我有两个应用程序 帖子 董事会。 我需要在电路板模板中创建网址链接,以便从帖子应用中查看。
我的根urls.py:
urlpatterns = [
url(r'^', include('boards.urls')),
url(r'^', include('posts.urls', namespace="posts")),
]
posts.urls:
# -*- coding: utf-8 -*-
from django.conf.urls import include, url
from views import (
listofposts,
create_post,
detail,
update_post,
category,
)
urlpatterns = [
url(r'^create/',
create_post ,
name='create_post'),
url(r'^category/(?P<slug>[-\w]+)/$',
category,
name='category'),
url(r'^(?P<slug>[-\w]+)/edit/$',
update_post,
name = 'update_post'),
url(r'^(?P<slug>[-\w]+)/$',
detail,
name = 'detail'),
url(r'^$',
listofposts ,
name='listofpost'),
]
开发板模板链接
<a class="navbar-brand" href="{% url 'posts:listofposts' %}">Home</a>
我弄错了:
例外值:
Reverse for 'listofposts' not found. 'listofposts' is not a valid view function or pattern name.