在我的模板上,我有这个
<a href="{% url 'call_donation' event=event.id %}" class="button" >Pitch in</a>
on views.py
def callDonation(request, event_id):
donation = DonationOrder.create(event_id)
storecod = Store.getStoreCode()
url = "https://www.externallink.com/pay/payment.asp?codtienda=%s&numcompra=%s&mount=" % (storecod, donation.order_id)
return HttpResponseRedirect(url)
on urls.py
url(r'^events/(\d+)/$', views.callDonation, name="call_donation")
但是
Reverse for 'call_donation' with arguments '()' and keyword arguments '{u'event': 4L}' not found. 1 pattern(s) tried: ['events/(\\d+)/$']
我迷失了应该改变什么才能让它发挥作用
答案 0 :(得分:3)
您必须在urlpatterns
中指定关键字名称,如下所示:
url(r'^events/(?P<event_id>\d+)/$', views.callDonation, name="call_donation")
此外,您必须确保在模板中传递了正确的关键字名称(例如event_id
而不是event
)。