سؤال

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')
(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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top