开发者

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

开发者 https://www.devze.com 2023-04-09 20:17 出处:网络
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

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

精彩评论

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

关注公众号