Coderaemon
Coderaemon

Reputation: 3867

Static Root / Url not working ?

In my settings.py mention:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

My folder structure

project_name
   static
     bootstrap
   settings
      settings.py

I am not able to access the static files. Though If I add STATIC_DIRS( and comment STATIC_ROOT) as below I can access the static files.

STATICFILES_DIRS = (
     os.path.join(BASE_DIR, "static"),
)

Upvotes: 0

Views: 1653

Answers (1)

utkbansal
utkbansal

Reputation: 2817

There is a difference between static root and staticfiles dirs

STATICFILES_DIRS tells django where to look for the static files apart from the standard app directories.

STATIC_ROOT tells where to collect all the static files on using the collectstatic command.

You need to set STATIC_ROOT to some other path from where your webserver (nginx) can server them directly in production.

Upvotes: 4

Related Questions