V
V
Vitaly Kaigorodov2021-04-17 06:51:04
Django
Vitaly Kaigorodov, 2021-04-17 06:51:04

STATIC_ROOT = os.path.join(BASE_DIR, 'static') why doesn't define os?

Hello. I prescribe the path where django will save files. When adding the line to the settings "STATIC_ROOT = os.path.join(BASE_DIR, 'static')" os is underlined as an error. When adding to the beginning of the Import os file, the error is fixed, will it be correct? Or is this kind of line relevant only for mac? I have windows.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-04-17
@cortez95

Vitaliy Kaygorodov , you are installing Django 3.x, the settings.py file does not use the os module by default (there is no import os at the beginning of the settings.py file), so when you copy STATIC_ROOT = os.path.join(BASE_DIR, 'static') from another project where the os module was used in the settings, os is underlined as a non-imported module. It has nothing to do with Windows or MacOS. If you want to use the os module in settings.py, you must first import it import os

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question