的模板的HTML
<p>
<a href="{% url 'courses:enrollment' courses.slug % }" class="pure-buttonprimary-button">Inscreva-se</a>
</p>
URLS.py
urlpatterns = [
url(r'^$', index, name = 'index'),
#url(r'^(?P<pk>\d+)/$', details, name = 'details'),
url(r'^(?P<slug>[\w_-]+)/$', details, name = 'details'),
url(r'^(?P<slug>[\w_-]+)/inscricao/$', enrollment, name = 'enrollment'),
]
Url找不到指定的路径。
答案 0 :(得分:2)
标记末尾的%
和}
之间有空格。
{% url 'courses:enrollment' courses.slug % }
^
将其更改为
{% url 'courses:enrollment' courses.slug %}
由于您在标记courses
中使用了名称空间courses:enrollment
,因此应在app_name
文件中设置courses/urls.py
。
app_name = 'courses'
urlpatterns = [
...
]
答案 1 :(得分:0)
您在网址反转中使用“课程”一词,即使它从未定义过。请尝试使用此功能:| OrderID | DateOrdered | EnteredById | OtherData | OtherData2 |
-----------------------------------------------------------------------
| 1 | 2/2/2017 | 3 | asdf | sadfsf |
| 2 | 2/2/2017 | 4 | asdf | sadfsf |
| 3 | 2/3/2017 | 4 | asdf | sadfsf |
| 4 | 2/4/2017 | 3 | asdf | sadfsf |
| 5 | 2/4/2017 | 4 | asdf | sadfsf |
| 6 | 2/6/2017 | 5 | asdf | sadfsf |