TemplateSYntax error : no module named
I pretty much know what i have to do , yet it doesn't work . Maybe your fresh eye will see the problem .
So .. My project name is : pro . Its location is /home/username/pro/
I have several application in pro folder, like : blog , comments etc. Everything works fine. But if i change the structure for apps from pro/blog , pro/comments to pro/apps/blog/, pro/apps/comments/ i get TemplateSyntax error: no module named ..... everytime i try to import application in settings.py.
Here is my apache main configuration , there is some more , but not relative to this topic :
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE pro.settings
PythonDebug On
PythonPath "['/home/username/'] + sys.path"
</Location>
As i understand my problem , the reason why it gives me this error because path to applications is not in python path. Yet 开发者_运维技巧when i try to change python path to : PythonPath "['/home/username/','/home/username/pro/','/home/username/pro/apps/'] + sys.path" . Nothing changes.
Add __init__.py
to the folder containing your apps.
PS: Adding pro/apps
to your pythonpath would make your apps resolvable via INSTALLED_APPS=('blog',)
.
It appears that you forgot to put a __init__.py
in your apps
directory to make it a package. It must be a package for you to be able to import things from it in Python.
精彩评论