As the templates
folder, needs to be configured, you need to also configure the static
folder as well.
For that, first we shall create a static folder in the base directory of our project.
Then, we need to specify this in the settings.py
file as well.
STATIC_URL = '/static/'
STATICFILES_DIRS=[os.path.join(BASE_DIR, "static"),]
This will configure the static files that are present in the base directory of your project.
Note : This will only work, when the debug mode is on, when you move on to production and turn off the debug mode, you would need to specify STATIC_ROOT
instead of STATICFILES_DIRS
.
STATIC_ROOT = os.path.join(BASE_DIR, "static")
Alternatively, it can also be specified within an if else statement, so no need to change it everytime you switch between debug mode.
STATIC_URL = '/static/'
if DEBUG:
STATICFILES_DIRS=[os.path.join(BASE_DIR, "static"),]
else:
STATIC_ROOT = os.path.join(BASE_DIR, "static")