python - Regular Expression in URL Not Working -


i have below url pattern , when trying access saying page not found

url(r'^getrequest/(add|edit|delete)/(\d+)/', 'cms_graph.views.test_data', name='cms_data'), 

i have html page pattern.

view.py

def test_data(request, data , id):    title = "got request %s" %(request.meta['remote_addr'])    print request.meta['remote_addr'],data,id    if (request.meta['remote_addr'] == '172.20.115.137'):        download_data(data, id)    context = {             "titleofpage" : title             }    return render(request,'test.html', context) 

test.html

<h1>{{titleofpage}}</h1> 

where doing wrong?? m trying open http://127.0.0.1:8080/getrequest

in order open http://127.0.0.1:8080/getrequest need have specified url pattern r'^getrequest/' (note: , have append_slash setting true, different story).

with specified url pattern, of urls below valid (as example):

http://127.0.0.1:8080/getrequest/add/1 http://127.0.0.1:8080/getrequest/edit/5 http://127.0.0.1:8080/getrequest/delete/9 

you can read more on url dispatching in django docs.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -