47

I'm using Django 1.3 and I realize it has a collectstatic command to collect static files into STATIC_ROOT. Here I have some other global files that need to be served using STATICFILES_DIR.

Can I make them use the same dir ?

Thanks.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
  • [Please folllow this link](https://stackoverflow.com/questions/12161271/can-i-make-staticfiles-dir-same-as-static-root-in-django-1-3) - I have found the answer from stackoverflow – Madiyor Jan 22 '20 at 06:21

1 Answers1

93

No. In fact, the file django/contrib/staticfiles/finders.py even checks for this and raises an ImproperlyConfigured exception when you do so:

"The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting"

The STATICFILES_DIRS can contain other directories (not necessarily app directories) with static files and these static files will be collected into your STATIC_ROOT when you run collectstatic. These static files will then be served by your web server and they will be served from your STATIC_ROOT.

If you have files currently in your STATIC_ROOT that you wish to serve then you need to move these to a different directory and put that other directory in STATICFILES_DIRS. Your STATIC_ROOT directory should be empty and all static files should be collected into that directory (i.e., it should not already contain static files).

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
  • 10
    so where can I put the static files that belong to the website, but not to a specific app? – lmiguelvargasf Jul 12 '16 at 00:32
  • 1
    That exception only happens when launching django manually. When configured with an Apache server for example, it works like a charm. It also seems correct to me because all the admin files are collected under `static/admin/`. Are there any potential problem that could happen doing so? – Gianpaolo May 20 '19 at 08:41