Django newbie here. I have trouble understanding the meaning of:
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
and
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') STATICFILES_DIRS = ( os.path.join(os.path.dirname(BASE_DIR), "static", "static"), )
What's happening here?
I take it the "file" is the settings.py file we are in (?), so the BASE_Dir is two folders up from that...? i.e. the one with manage.py in it?
So the STATIC_ROOT, will be one? or two? directories up from the BASE_DIR. Will the STATIC_ROOT FOLDER be made for me? Or do I have to make one called "static"?
└── MY_PROJECT ├── BASE_DIR │ ├── MY_APP │ │ └── settings.py │ └── manage.py └── static
Is the above right for this example? Then what the heck / where the heck will the STATIC_FILES_DIRS be?
BASE_DIR is your Django project directory. The same directory where manage.py is located.
The base directory is the path on your system that corresponds to the path where your application will be installed. In other words, it's the local representative of %AppDir%.
An absolute file path describes how to access a given file or directory, starting from the root of the file system. A file path is also called a pathname. Relative file paths are notated by a lack of a leading forward slash.
dirname() method in Python is used to get the directory name from the specified path. Parameter: path: A path-like object representing a file system path. Return Type: This method returns a string value which represents the directory name from the specified path.
BASE_DIR is your Django project directory. The same directory where manage.py is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With