Viktor
Viktor

Reputation: 580

Django applications path

  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 = (
    .....
    'blog',
    '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

Upvotes: 1

Views: 401

Answers (1)

Thierry Lam
Thierry Lam

Reputation: 46254

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

Upvotes: 3

Related Questions