[Answered ]-TypeError at /confirmemail/amlqctnhel/confirmemail() takes exactly 2 arguments (1 given), why?



In a URLconf, you need to use capturing groups in your regex to achieve positional or keyword arguments in your view. If you use a named capture group, then keyword arguments are used; otherwise, positional arguments are used.

Here is what your url() line should look like:

url(r'^confirmemail/([a-zA-Z0-9]{10})/$', 'blog.views.confirmemail'),
# or
url(r'^confirmemail/(?P<token>[a-zA-Z0-9]{10})/$', 'blog.views.confirmemail'),

The first form uses a positional argument (and positional arguments are ordered by the capture groups in the URL). The second form uses a keyword argument, in this case token. The second form is more characters but will also be safe against parameter reordering.


You arent capturing a pattern in your url so its not passing a value for your token parameter

url(r'^confirmemail/([a-zA-Z0-9]{10})/$', 'blog.views.confirmemail'),

Note i have wrapped your pattern in a capture group


Leave a comment