Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
paths in django 'settings.py'
#1
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-base 
what 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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Azure Function App Configuration Settings jdb1234 1 2,083 Oct-16-2020, 10:54 AM
Last Post: ndc85430
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam
  [Selenium] Element Visible / Invisible | Delay - Best Settings? digitalmatic7 2 6,183 Nov-19-2017, 03:54 PM
Last Post: digitalmatic7
  location settings for Django Uwsgi Nginx Configuration for production sandyman 0 2,946 Sep-15-2017, 09:08 AM
Last Post: sandyman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020