[Fixed]-Django 1.9 pushing our code to go live today but have static directory issue

1๐Ÿ‘

โœ…

You can store your static files in multiple folders which can reside anywhere

It will look like this in settings

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    #You can have multiple directories here
)

Set the STATIC_ROOT like this in settings

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

When you run $ python manage.py collectstatic
This will copy all files from your static folders into the STATIC_ROOT directory.

The purpose of this to gather all static files in a single directory so you can serve them easily.

**Note

Set the base directory in settings

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
๐Ÿ‘คvasudokala

0๐Ÿ‘

Basically what you have to do, is to tell django STATICFILES_DIR settings where all your static folder live

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    os.path.join(BASE_DIR, 'mycssfolder'),
    os.path.join(BASE_DIR, 'otherstaticfolder')

]

so when you run djangoadmin collecstatic command it looks into all those folder for static files.

๐Ÿ‘คpitaside

Leave a comment