syv
syv

Reputation: 3608

Regex url pattern for django

I need to define an URL pattern for the below URL

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

I tried the following but I get 404

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

What am I doing wrong here.

Error message that Im getting is

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

Upvotes: 1

Views: 117

Answers (1)

falsetru
falsetru

Reputation: 368894

You can't match query string in Django url pattern.

Use the following pattern:

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

And in the view, use request.GET to get GET parameters:

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

Upvotes: 1

Related Questions