urls.py
urlpatterns = patterns('',
(r'^page/\w+/$', get_page),
(r'', main),
)
calling : http://localhost:8081/page/cricket
calls the main, function and not get_page
How can I make this work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The regular expression is wrong. It would match http://localhost:8081/page/cricket/ or http://localhost:8081/page/dog/. It does not match http://localhost:8081/page/cricket because the regular expression requires a / at the end.
Based on your comments and question you may want something like:
This would also pass everything after
page/to the the get_page function in the named parameter ‘loc’.If you’re having trouble with the meaning of the special symbols please refer to Python’s regular expression reference.