How to access directory file outside django project?
<p>I have my Django project running on RHEL 7 OS. The project is in path <code>/root/project</code>. And project is hosted on httpd server. Now iam trying to access a file out side the directory like <code>/root/data/info/test.txt</code></p>

<p>How should I access this path in views.py so that I can read and write file which is outside the project directory ? I tried to add the path in <code>sys.path</code> but it didn't work. Read and write permission are also give to the file. </p>

<p>Add the following lines to your <code>settings.py</code></p>

<pre><code>import os
..
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
FILES_DIR = os.path.abspath(os.path.join(BASE_DIR, '../data/info'))
</code></pre>

<p>Then you can use in your view</p>

<pre><code>from django.conf import settings
import os
..
file_path = os.path.join(settings.FILES_DIR, 'test.txt')
</code></pre>

python django apache httpd.conf