![](/img/trans.png)
[英]Django NoReverseMatch error Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found
[英]Python Django error NoReverseMatch Exception Value: Reverse for 'updatecontact' with no arguments not found
我有一個更新數據庫中數據的功能。 這是我的網址:
url.py
url(r'updatecontact/(?P<id>\d+)/$',views.updatecontact,name="updatecontact"),
template.html
<td><a href="/updatecontact/{{a.id}}/">Update</a></td>
我收到錯誤消息:
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'updatecontact' with no arguments not found. 1 pattern(s) tried: ['updatecontact/(?P<id>\\d+)/$']
將您的網址更改為
url(r'^updatecontact/(?P<pk>\d+)/$',views.updatecontact,name="updatecontact"),
在您的模板中,您可以使用
{% url 'updatecontact' a.pk %}
而不是輸入整個網址
嘗試在網址中添加斜杠/
。 喜歡:
url(r'/updatecontact/(?P<pk>\d+)/$',views.updatecontact,name="updatecontact"),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.