[Fixed]-Regex to accept anything in url django

1👍

Your regex basically says

 reply/something here/   

or
reply//

Hence the reason that you are getting the redirect. Easiest thing is probablly to use two url patterns here or

url(ur'^reply/(.*)/?$', views.visit),

But the above has the undesirable side effect of links without trailing slashes not being directed to the version with the trailing slash

0👍

Those inputs are get parameters, and you don’t need to match them in a url – if anything matching them in a url would make it harder for yourself since you’d then need to parse them in a view yourself.

Instead just change your url to just the /reply/ and lookup all the get parameters in the request.GET dictionary in the view

url(ur'^reply/$', views.visit),

dev visit(request):
    anything = request.GET['input']
    agent_type = request.GET.get('agent_type')

Leave a comment