E
E
Eugene-1232020-12-01 15:38:00
Django
Eugene-123, 2020-12-01 15:38:00

What does '/' in 'NAME': BASE_DIR/'db.sqlite3' mean in Django?

Opened settings.py, and there:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

What does slash mean? Is this the correct syntax?
If you write in the interpreter:
BASE_DIR = 'some_dir'
BASE_DIR / 'templates'

then it will throw an error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-12-01
@Eugene-123

If you look closely, BASE_DIR is not a string, but an instance of the pathlib.Path class, for which the / operator is defined between Path and str. Doc https://docs.python.org/3/library/pathlib.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question