0

I have following django rest api end point

url(r'^api/email-verification/(?P<pk>[0-9]+)/$', EmailVerificationApiView.as_view(), name="email-verified")

and following is the html template where i am applying this api to verify a user, i.e after clicking the following Activate link, the above mentioned api endpoint will be called and in back end the user will be flaged verified, but with the click of the html button it doesn't call the 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>

after clicking the Actvate button, its redirecting me another page which give following statement

    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 am relatively new in django and django rest api.Is there any other special way to call a django rest api in django template url tag?

In mention, the api is a POST api and the above given html template is a email template.

Md. Tanvir Raihan
  • 4,075
  • 9
  • 37
  • 70

1 Answers1

-2

In your template you have

{% url 'email-verified' user_id %}

It should be:

{% url 'email-verified' pk=user_id %}
Clément Denoix
  • 1,504
  • 11
  • 18