In the documentation https://docs.djangoproject.com/en/dev/howto/static-files/
I read that static files should be put with their respective apps and called upon with
Almost everything about django static is related to the django.contrib.staticfiles
app. Although you need to custom edit many settings to make staticfiles
work, what is does is simple. It provides a collectstatic
command which collects static files from different app and put them into a single directory.
The answer to your first question is simple: Put those common static files under the /static
directory of your django project directory. In your case, it's mysite/static
.
Reason: First, it's the official way. You can find the following code in official doc: Managing static files (CSS, images). Second, it's reasonable. Since we put static files only used in a single app under project/appnane/static/...
The project's static dir should follow the same name pattern.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"), # That's it!!
'/var/www/static/',
)
As I said in the comment, your should not set STATIC_ROOT
to project_absolutr_path/static
. Because that directory is user to put css app static files. You don't want the collectstatics command to pollute that directory especially when you are using a version control system like git/svn.
STATIC_ROOT
really depends on the way you host these static files(Apache, Nginx, S3, CDN, Paas like heroku)