【发布时间】:2026-02-05 19:50:02
【问题描述】:
我有一个这样的网址:
url(r'^(?P<user_id>\d+)/profile/$', views.ProfileView.as_view(), name='profile'),
当用户点击Update Profile 时,我会更新表单并使用messaging framework 重定向到与message 相同的配置文件URL。
# views
# Use the message framework to pass the message profile successfully updated
messages.success(request, 'Profile details updated.')
# Redirect to the same view with the profile updated successfully message
return HttpResponseRedirect(reverse('profile', args=(request.user.id,)))
但我收到此错误:
NoReverseMatch at /5/profile/
Reverse for 'profile' with arguments '(5L,)' and keyword arguments '{}' not found.
怎么了?
【问题讨论】:
标签: django django-views django-urls