Django NoReverseMatch针对特定的美国

2024-10-02 20:36:03 发布

您现在位置:Python中文网/ 问答频道 /正文

这很令人惊讶,我似乎无法摆脱它

下面的代码适用于大多数用户,但当我尝试为userSSENOR呈现链接时,代码会中断,并生成以下错误:

NoReverseMatch at/tofollow/ 找不到参数为“(u'SSenior',)”且关键字参数为“{}”的“profile”的反转。已尝试1个模式:[“用户/(?P\w+/$”]

url.py

url(r'^tofollow/$', views.tofollow, name='tofollow'),
url(r'^user/(?P<username>\w+)/$', views.profile, name='profile'),

template.html

<a href="{% url 'mysite:profile' users.username %}">@{{user.username}}</a>

Tags: 代码用户nameurl参数链接错误username