I am developing a django application. On the development server, everything works just fine. On the production server (using apache), nothing is working.
1/ I have the error TemplateDoesNotExist at /.
In my settings.py file:
SITE_ROOT = os.path.abspath(os.path.dirname(__name__))
. This is the project root path.
templateDir = os.path.join(SITE_ROOT, 'templates/')
TEMPLATE_DIRS = (
templateDir
)
This is the templates path.
2/ If I change SITE_ROOT with the absolute path of the project:
SITE_ROOT="/var/www/europolix"
Templates seem to be recognize but I have another mistake: No module named getEurlexIdsFunctions Here is the code:
import sys
sys.path.append('import')
import getEurlexIdsFunctions as eurlexIds
I think that once again the problem comes from a relative path. Apache seems to search 'import' in "var/www/" and not in "var/www/europolix/". Am I right?
Here is my apache configuration:
WSGIScriptAlias /europolix /var/www/europolix/europolix/wsgi.py
WSGIPythonPath /var/www/europolix/
<Directory /var/www/europolix/>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Is it a problem of root path not recognized, or is there another problem?
Many thanks.
in django project in file wsgi.py i add this 3 lines
Well, a couple of things. When working with
settings.py
is better to declare all the paths as absolute paths. I see in your code that you have this linefor site's root but I think is better if you use
__file__
global variable instead of__name__
. Like this:I have a django app in production server and all I had to add to my
httpd.conf
aboutwsgi
was theload_module
directive and this line inside the virtual hostspecifying the alias to the
django.wsgi
script as the root.Then in
django.wsgi
script I have this code:I think you're better off working with absolute paths and when you got it all working then try to accommodate it for your needs with maybe relative path if you have to.
Hope it helps.