Python NoReverseMatch at/accounts/detail

Python NoReverseMatch at/accounts/detail,python,html,django,Python,Html,Django,我有个错误,NoReverseMatch在/accounts/detail 找不到参数为“()”且关键字参数为“{}”的“上载”的反转。尝试了1种模式:[u'帐户/上载/(?P\d+/$')]。 我写了detail.html,就像 <body> <a href="{% url 'accounts:upload' %}"><img src="{% static 'accounts/Send.jpg' %}" alt="SEND"></a> &l

我有个错误,NoReverseMatch在/accounts/detail 找不到参数为“()”且关键字参数为“{}”的“上载”的反转。尝试了1种模式:[u'帐户/上载/(?P\d+/$')]。 我写了detail.html,就像

<body>
   <a href="{% url 'accounts:upload' %}"><img src="{% static 'accounts/Send.jpg' %}" alt="SEND"></a>
</body>
在URL.py中

urlpatterns = [
    url(r'^detail$', views.detail,name='detail'),
    url(r'^photo/$', views.photo, name='photo'),
    url(r'^upload/(?P<p_id>\d+)/$', views.upload, name='upload'),
]
urlpatterns=[
url(r“^detail$”,views.detail,name='detail'),
url(r“^photo/$”,views.photo,name='photo'),
url(r'^upload/(?P\d+/$),views.upload,name='upload'),
]

当我访问时,会发生这些错误。我如何解决这个问题?我应该写什么?

在您的
url.py
中,您的上载url需要参数
p\u id

url(r'^upload/(?P<p_id>\d+)/$', views.upload, name='upload')
#                 ^^^
your_url = reverse('accounts:upload', p_id=123)
或者,在模板中:

<a href="{% url 'accounts:upload' 123 %}">Click me</a>

您需要将
p\u id
传递到模板中的url
<a href="{% url 'accounts:upload' 123 %}">Click me</a>