4

I have a Dreamhost shared server hosting Passenger Python/Django. Currently I have a global folder (/public/static, /public/media) that collects non-python files. When I do "collectstatic" all my app's */static files get copied over to the global /public/static folder. Good so far.

1) I'm getting tired using collectstatic. I want to remove my app's */static folder and place their files in the global /public/static. This works on Dreamhost since Passenger Python points Apache's Document Root to /public, which will retrieve /public/static and /public/media correctly. But on the development side I do not have such a functionality (under python manage.py).

2) Any optimizations for static/cached files under Dreamhost/shared hosting?

Below are my settings:

Website Settings:

STATICFILES_DIRS = (
    ABS_PATH + '/???/???/static/', #My App's static dir
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder'
)

TEMPLATE_DIRS = (
#ABS_PATH + '/hdrtoronto/hdrtoronto/templates/'
ABS_PATH + '/templates/'
)

Urls.py:

if os.environ.get("django_dev", None):
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
Exegesis
  • 1,028
  • 1
  • 18
  • 47

1 Answers1

3

STATIC_ROOT and MEDIA_ROOT need to be located outside of your Django project. Hence the collecstatic management command, to collocate all your static resources at an external location, as it's meant to be.

I'd advise you to reconsider how your managing your static files. Your about to do something terribly wrong and I'm afraid your completely missing the point and going against proper framework behavior.

Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114
  • Yes, STATIC_ROOT, MEDIA_ROOT are placed outside the project. Actually, on production it's working perfectly (all files placed in global /static) however for development (where the question comes in) doesn't. It doesn't make sense to have GIGS of images in the app's /static and then have that copied to the global /static. If **collectstatic** in the end copies files over to global /static, then I should have the ability to not deal with it during development. Django's implementation of app modularization is a complete overkill especially when most of my sites are domain-specific/coupled. – Exegesis Oct 23 '12 at 03:34
  • 3
    I completely understand that you might not agree with Django's architectural breakdown into Django applications, it is a very unique framework feature, but these static resources form a part of your application. Web servers have their own preferred locations for assets, with regulated access--since you typically do not give Web servers access and neither do you write content, e.g. uploads, to paths that are in your source packages, hence the external `STATIC_ROOT`, `MEDIA_ROOT` and the need for a `collectstatic` command. – Filip Dupanović Oct 29 '12 at 23:51