开发者

Django url pattern with or without <projectName> as path to view?

I'm new to Django and been reading the http://djangobook.com and finds that the following two patterns work the same way with no hiccups for project named mysite and views.py on the project root with a function named hello.

(r'^hello/$', 'mysite.views.hello')
开发者_JS百科(r'^hello/$', 'views.hello)

May I know what's the practice like? with or without the proceeding Project namespace? And if I may, why?

'' is the prefix for these patterns.


the fisrt one is because the mysite dir is in your python path;

the second one is because when your run the project, the current path will add to python path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜