我有一个包含两个字段user_id和代码的网址:
url(r'^account_completion/(?P<user_id>d+)$/(?P<code>[-w]+)$', confirm_verification, name="confirmation_link"),
我尝试从shell获取错误
In [2]: reverse('confirmation_link', args=(123,'aaaaaaa'))/home/samuel/Documents/code/kazi/django_project/django_project/urls.py:34:
t = url(prefix=prefix, *t)
---------------------------------------------------------------------------
NoReverseMatch Traceback (most recent call last)
...
...
NoReverseMatch: Reverse for 'confirmation_link' with arguments '(123, 'aaaaaaa')' and keyword arguments '{}' not found. 1 pattern(s) tried: ['register/account_completion/(?P<user_id>d+)$/(?P<code>[-w]+)$']
答案 0 :(得分:1)
您的网址正则表达式中有错误。请尝试以下方法:
url(r'^account_completion/(?P<user_id>\d+)/(?P<code>[-\w]+)$',
confirm_verification, name="confirmation_link"),