我正在Django項目上工作,我有一個html網頁,並從網頁我想通過一個Id並通過該ID,更新記錄。我有url設置和html頁面url重定向。我正在傳遞所需的url,但我得到了模式匹配錯誤。我嘗試了一切,出於某種原因,它無法正常工作。有誰知道什麼是oging或可以幫助我找出是什麼導致此錯誤。我會在下方附上所有的信息:Django - url被重定向時不匹配任何模式
這裏是URL鏈接:
url(r'^(?P<source_id>[\w+][0-9]+)/default_source/$', views.setDefaultSource, name='default_source'),
下面是HTML文件:
<p>{{account.user.username}}, {{ account.source_name }}, {{ account.source_id }},
{{ account.status }}
<a href="{% url 'default_source' account.source_id %}">Make Default</a>
這裏是views.py:
def setDefaultSource(request, source_id):
currentUser = loggedInUser(request)
currentSource = Dwolla.object.get(source_id = source_id)
update_source = currentSource
update_source.status = 2
update_source.save()
return redirect('home_page')
這是我得到的錯誤:
NoReverseMatch at /linked_accounts/
Reverse for 'default_source' with arguments '('https://api-sandbox.dwolla.com/funding-sources/3021030d-0175-41f1-8bce-4625b8eae0fc',)' not found. 1 pattern(s) tried: ['(?P<source_id>[\\w+][0-9]+)/default_source/$']
源ID是下面的'的https:// api-sandbox.dwolla.com /資金來源/ 3021030d-0175-41f1-8bce-4625b8eae0fc' @zhiyucao –