[Fixed]-How to include static files from outside the project root in django


Add the absolute path to that directory in STATICFILES_DIRS setting. You can calculate from the settings.py dir, just add a variable like this:

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

And then add the static files path, ie:

STATICFILES_DIRS = [os.path.abspath(os.path.join(
        BASE_DIR, '..', 'conf', 'project', 'appname', 'static'))]

In production, collectstatic will pick it up.

For more info check out Django’s howto manage static files.


Leave a comment