linux - File found by Django server but not by Apache/mod_wsgi -
i've got django app when run "manage.py runserver 0.0.0.0:80" works fine, when run apache2 server tells me "no such file or directory"
i reckon it's telling apache path in, i've done obvious:
wsgiscriptalias / /home/mywebsite/myproject/wsgi.py wsgipythonpath /home/mywebsite <directory /home/mywebsite/myapp> <files wsgi.py> order deny,allow require granted </files> </directory> <directory /home/mywebsite> //i thought might give access root folder order deny,allow require granted </directory>
note file in root of project, next manage.py. app able display front page, ajax fired 1 of buttons fails due above mentioned file error.
i must missing how specify file path.
the code access file this:
with open('demo.txt') fp: etc...
to reiterate, works fine when run django server. apache runs main page fine, falls on when looking file.
what need change?
one way set project path in settings file: (if it's in project root)
base_dir = os.path.dirname(os.path.dirname(__file__)) django.conf import settings open(os.path.join(settings.base_dir, 'demo.txt')) fp: ...
it consistent across installations of project , can debug base_dir locally.
Comments
Post a Comment