Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the absolute path of BASE DIR?

Tags:

static

django

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?

like image 653
David Blake Avatar asked Sep 05 '14 14:09

David Blake


People also ask

What is the base Dir in Django?

BASE_DIR is your Django project directory. The same directory where manage.py is located.

What is base dir?

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%.

What is absolute path in Python?

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.

How do I get the base of a directory in Python?

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.


1 Answers

BASE_DIR is your Django project directory. The same directory where manage.py is located.

like image 105
Jon Avatar answered Nov 10 '22 14:11

Jon