我有以下django rest端点
url(r'^api/email-verification/(?P<pk>[0-9]+)/$', EmailVerificationApiView.as_view(), name="email-verified")下面是我应用此api来验证用户的html模板,即在单击以下Activate链接后,将调用上述api端点,并在后端对用户进行平版验证,但是单击html按钮后,它不会调用该api。
<body>
<tr>
<td class="button">
<div><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://" style="height:45px;v-text-anchor:middle;width:155px;" arcsize="15%" strokecolor="#ffffff" fillcolor="#ff6f6f">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial, sans-serif;font-size:14px;font-weight:regular;">My Account</center>
</v:roundrect>
<a href="{% url 'email-verified' user_id %}">
Activate
</a>
</div>
</td>
</tr>
<body>单击Actvate按钮后,它会重定向另一页,给出以下语句
Redirect Notice
The page you were on is trying to send you to an invalid URL (http:///api/email-verification/103/).
If you do not want to visit that page, you can return to the previous page..I在django和django rest中相对较新,在django模板url标记中还有其他特殊的方法来调用django rest吗?
在提到时,api是一个POST api,上面给定的html模板是一个电子邮件模板。
发布于 2017-11-18 08:50:20
在你的模板中
{% url 'email-verified' user_id %}它应该是:
{% url 'email-verified' pk=user_id %}https://stackoverflow.com/questions/47364158
复制相似问题