0

I'm not sure that my question is correct. I develop a web site on local machine and I can not understand how to setup a view which will be executed when I open a start page http://127.0.0.1:8000/

I've tried to write a url - url(r'^/', 'pages.views.home', name='home'), but when I go to browser it doesn't work.

Maybe I need to change settings.

4

1 回答 1

2

尝试使用以下 URL 正则表达式:

url(r'^$', 'pages.views.home', name='home')

第一个/不是正则表达式的一部分,因为它在与 URL 比较之前会自动删除。上面的表达式将匹配第一个/,仅此而已 -^表示“行的开头”并$表示结尾。

于 2013-08-24T09:04:30.620 回答