Shift N' Tab Shift N' Tab - 1 month ago 8
Python Question

Is there any way to use one static folder for all apps in django project

I would like to ask if it is possible to use one static folder for all your project apps in

django
? I'm building my app on
windows 10
.

Supposed that we have this structure:

src
...\projectFolder
......\__init__.py
......\settings.py
......\urls.py
......\wsgi.py
...\app1
......\app1
.........\static
...\app2
......\app2
.........\static
...\app3
......\app3
.........\static
...manage.py


To avoid multiple static folder each app i would like to make this structure so static folder is shared in all the applications with the same level directory of
projectFolder
.

src
...\static // this is static folder that must be shared with all the apps.
...\projectFolder
......\__init__.py
......\settings.py
......\urls.py
......\wsgi.py
...\app1
...\app2
...\app3
...manage.py


Is this possible?

Answer

This is documented (albeit possibly not in the most beginner-friendly way). What you want is to add your project's level "static" directory to settings.STATICFILES_DIRS.