Django static files on Dreamhost

I have shared hosting hosting Dreamhost Passenger Python / Django. I currently have a global folder (/ public / static, / public / media) that collects files other than python. When I do collectstatic, all my applications * / static files are copied to the global / public / static folder. Okay bye.

1) I get tired using collectstatic . I want to delete the application folder * / static and put my files in global / public / static. This works on Dreamhost, because Passenger Python points to the Apache Document Root to / public, which will properly load / public / static and / public / media. But on the development side, I do not have such functionality (under python manage.py).

2) Any optimization for static / cached files in Dreamhost / shared hosting?

Below are my settings:

Website Settings:

STATICFILES_DIRS = ( ABS_PATH + '/???/???/static/', #My App 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) 
+4
source share
1 answer

STATIC_ROOT and MEDIA_ROOT must be outside your Django project. Consequently, the collecstatic management collecstatic is to combine all your static resources in an external location, as it should have been.

I would advise you to reconsider how you manage your static files. Your task is to do something terribly wrong, and I'm afraid that you completely missed the point and went against the correct behavior of the frame.

+3
source

Source: https://habr.com/ru/post/1441423/


All Articles