开发者

Django applications path

开发者 https://www.devze.com 2023-02-21 18:29 出处:网络
Project name: pro Project location : /home/cha0s/pro/ Applications location:/home/cha0s/pro/apps/, where are folders of different apps like blog, comments etc...
  1. Project name: pro
  2. Project location : /home/cha0s/pro/
  3. Applications location: /home/cha0s/pro/apps/ , where are folders of different apps like blog, comments etc...

Apache configuration:

 <Location "/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE pro.settings
        PythonDebug On
        PythonPath "['/home/cha0s/','/home/cha0s/pro/apps/']
+ sys.path"  </Location>

So the question is : with following configuration , to import an app in INSTALLED_APPS , for example blog i need to write just

INSTALLED_APPS = (
    .....
    'blo开发者_开发技巧g',
    'gallery',
    ......
)

but if i take this line '/home/cha0s/pro/apps/' away from python path , by my logic then to install a module for example blog , i need to write full path like pro.apps.blog and it should work , but it doesn't . How come ?

SOLUTION:

Thanks Lam . Don't know how to mark Thierry Lam answer correct , so i'll just write it here.

init.py file must be created in apps directory even if it is just a directory with no files. Then there is no need for '/home/cha0s/pro/apps/' line in apache configuration , and modules can be declared like pro.apps.blog


Do you have the following file apps/__init__.py?

0

精彩评论

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