Forums

Collectstatic: where is it putting the files, and why?

I have a static directory located here:

home > my_username > my_app > static

which contains subfolders for js, css, admin, etc.

I ran collect static and now all those subfolders are duplicated in my my_app folder, that is one level up

In my settings.py file I have

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'

 STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/my_username/my_app/static/',
'/home/my_username/.local/lib/python3.3/site-packages/adminsortable/static/',

 )

What did I do wrong, and how can I clean it up? The app seems to function fine, as well as the admin, but it's rather messy at the moment.

In Django each app in a project can have static files, so in order to make it easy to serve all the static files from the web server instead of through Django, collectstatic puts them all in one place. Then it only takes one configuration of the web server to set the static directory, instead of having to do one configuration per app. collectstatic puts the files it finds into the directory STATIC_ROOT specified in your settings.

My guess is it's working, either because you're using the Django staticfiles app and Django is serving your static files or because you only have one app and a static files mapping directly to the static files directory for the app, or because you have multiple apps and a static files mapping for each of them.

Thanks, — the issue was that I only had 'static_url' defined, not 'static_root', I believe