paths in django 'settings.py' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: paths in django 'settings.py' (/thread-13516.html) |
paths in django 'settings.py' - nzcan - Oct-19-2018 in a new django-project in the file 'settings.py' we will find the first line of code: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))the comment above this line of code says: '# Build paths inside the project like this: os.path.join(BASE_DIR, ...)' down the code the object 'BASE_DIR' is used (mentioned) just one more time in the 'DATABASES' dict-data-type object: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }as i understand the object 'BASE_DIR' will contain the path to the data-base of the future website. but what will happen if we edit the code like this (for example): BASE_DIR = /home/tony/python-project/ ... data-basewhat is the purpose of using the 'os-module'? do i correctly understand that the line ... 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),will create a data-base for the website automatically with the name 'BASE_DIR' so there will be no need for me to write a data-base for the website manually? |