[Solved]-How to access directory file outside django project?

10👍

Add the following lines to your settings.py

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'))

Then you can use in your view

from django.conf import settings
import os
..
file_path = os.path.join(settings.FILES_DIR, 'test.txt')
👤atn

Leave a comment