To do this, I placed it in the settings module. In settings.py add, for example, MY_LONG_QUERY = 'from FOO select BAR...' . Then, in your opinion, just download it from these settings:
from django.conf import settings settings.MY_LONG_QUERY
But this does not really answer your question. Assuming that the permissions and everything is correct, save the link to your project root in your settings as follows:
ROOT_PATH = os.path.split(os.path.abspath(__file__))[0]
And again in your view, open the file as follows:
from django.conf import settings def read_from_database(request): f = open(os.path.join(settings.ROOT_PATH, 'myfile.db'))
jro
source share