djang的Regex url模式

2024-09-27 07:28:35 发布

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

我需要为下面的URL定义一个URL模式

http://myurl:8080/authentication/agent/newpassword/?resetPassword=textValue&agentCode=textValue

我试过以下方法,但得到404

url(r'^authentication/agent/newpassword/(?P<resetPassword>.+)(P<agentCode>.+)/$', passwordValidation),

我做错什么了。你知道吗

我收到的错误消息是

"GET /authentication/agent/newpassword/?resetPassword=textValue&agentCode=textValue HTTP/1.1" 302 0

Tags: 方法httpurlauthentication定义错误模式agent
1条回答
网友
1楼 · 发布于 2024-09-27 07:28:35

无法匹配Django url模式中的查询字符串。你知道吗

使用以下模式:

url(r'^authentication/agent/newpassword/$', passwordValidation),

在视图中,使用request.GET获取参数:

def passwordValidation(request):
    resetPassword = request.GET.get('resetPassword', '')
    agentCode = request.GET.get('agentCode', '')

相关问题 更多 >

    热门问题