#33001 closed New feature (wontfix)
ManifestStaticFilesStorage is problematic - need changes here
Reported by: | Man Python | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | 3.2 |
Severity: | Normal | Keywords: | Static |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
https://docs.djangoproject.com/en/3.2/ref/contrib/staticfiles/#manifeststaticfilesstorage
A subclass of the StaticFilesStorage storage backend which stores the file names it handles by appending the MD5 hash of the file’s content to the filename. For example, the file css/styles.css would also be saved as css/styles.55e7cbb9ba48.css.
I think we should have something like 'css/styles.css?55e7cbb9ba48' as ManifestStaticFilesHashRequest, without file changes.
For browser this changed hash creating request ouside cache.
Change History (5)
follow-up: 2 comment:1 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 3 years ago
Resolution: | wontfix |
---|---|
Status: | closed → new |
Replying to Carlton Gibson:
Hi. This behaviour has been unchanged since ManifestStaticFilesStorage was introduced in Django 1.7. You're welcome to make whatever adjustments you need in a subclass (or configure your webserver to route
styles.css?<HASH>
requests to the right file) but it's not something we can just change.
Well.. I think it should be changed as default with this settings to has static files due many problems around cache on servers and enviroment in case user can not recognize in first the problem around cache (not onlt CDN, etc. but dedicated solutions in panels for apache ngnix wsgi, pushion passenger).
You say "problematic" but don't explain that at all. Likely it's your set up but if you can narrow down a specific issue in Django we're happy to have a look.
Thanks
There is many issues.. but I tired to report all.
Eg.
?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.
STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "public/static") ] STATIC_ROOT = os.path.join(BASE_DIR, 'public/', 'static/') STATIC_DIR = os.path.join(BASE_DIR, 'public/', 'static/') MEDIA_ROOT = os.path.join(BASE_DIR, 'public/', 'media/')
Users on boards like stack suggesting to delete/comment - I still not understand the reason for this "separation".
STATICFILES_DIRS = [ os.path.join(BASE_DIR, "public/static") ]
https://stackoverflow.com/questions/27213752/collecting-staticfiles-throws-improperlyconfigured
Then sure.. working, but not the overided templates and css
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'public/', 'static/') STATIC_DIR = os.path.join(BASE_DIR, 'public/', 'static/') MEDIA_ROOT = os.path.join(BASE_DIR, 'public/', 'media/')
Many aps need the STATICFILES_DIRS from INSTALLED_APPS and if not exist, then django not starting
Then user starting combine with rename dirs, move dirs, and caching canchges.. the .pyc often not include changes in settings.py this doing problems (sure.. advanced user know about problem, but anyway something can be complicated and not included in right way - fast refresh server overloaded, this same on dev/debug in local what I meet [eg. debugpy lags]).
Hash refresh for static can help to see current stage/session in relation to code change (eg. ?unixtime).
Finally I have 2 dirs public and public2
STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "./public2/static") ] STATIC_ROOT = os.path.join(BASE_DIR, 'public/', 'static/') STATIC_DIR = os.path.join(BASE_DIR, 'public/', 'static/') MEDIA_ROOT = os.path.join(BASE_DIR, 'public/', 'media/')
This is not end..
The collecstatic sucsks.. it's not copying this same from site-packages\django\contrib\admin\static\
https://docs.djangoproject.com/en/3.2/ref/contrib/staticfiles/
Then overiding not working! Coz .css for overiding is differnt from site-packages\django\contrib\admin\static\admin\css\base.css
Eg. original is:
/* DJANGO Admin styles */ @import url(fonts.css); /* VARIABLE DEFINITIONS */ :root { --primary: #79aec8; --secondary: #417690; --accent: #f5dd5d; --primary-fg: #fff; --body-fg: #333; --body-bg: #fff; --body-quiet-color: #666; --body-loud-color: #000;
Copied
/* DJANGO Admin styles */ @import url(fonts.css); body { margin: 0; padding: 0; font-size: 14px; font-family: "Roboto","Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif; color: #333; background: #fff; }
Who can discover the detail? It's impossible if dev is not advanced.
Problematic, coz no logs around templates/loaders around with overriding or any of around.
What user doing next.. trying with .html similary.. creating "template" dirs in
project\static\admin\templates
or
project\app\admin\templates
project\app\view\templates
other experiments
I found many this cases in boards and recognized this as experiments, other confused action.
Eg. last talks on gitter django. I was not sure that with collectstatic the .html should was copied or not, and this same with other assets as js/css if current was changed (after django upgrade)
The funny, that all issues I meet after upgrade django to newer. This same with DJrest, other aps/addons.
This all made hard work around extends.
Next..
Users experimenting with
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ "admin/", "rest_framework/", "django_registration/" ], #'APP_DIRS': True,
Changing eg. to:
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ BaseDir/, "Templates" "admin/", "rest_framework/", "django_registration/" ], 'APP_DIRS': True,
or
'DIRS': [ BaseDir/, "Public" "admin/", "rest_framework/", "django_registration/" ],
'DIRS': [ BaseDir/, "Public2" "admin/", "rest_framework/", "django_registration/" ],
You know what I mind.. if not errors, logs, then experiments.. in browser logs have near ok all, but around mods from overiding it taking as orginal not moded files.
Eg. disonance is coming for favicon.ico always.. if static give files.. and in browser/django log
Not Found: /favicon.ico [10/Aug/2021 19:59:00] "GET /favicon.ico HTTP/1.1" 404 2640
Why?
Thx for attention.
https://gitter.im/django/django?at=610ed8ab025d436054ba2d55
follow-up: 5 comment:3 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I appreciate you'd like to reopen the ticket, but please follow the triaging guidelines with regards to wontfix tickets and take this to DevelopersMailingList.
The collecstatic sucsks.. it's not copying this same from site-packages\django\contrib\admin\static\
Please may I also refer you to the code of conduct for your consideration.
comment:5 by , 3 years ago
Replying to Mariusz Felisiak:
I appreciate you'd like to reopen the ticket, but please follow the triaging guidelines with regards to wontfix tickets and take this to DevelopersMailingList.
The collecstatic sucsks.. it's not copying this same from site-packages\django\contrib\admin\static\
Please may I also refer you to the code of conduct for your consideration.
Thats why any efforts not going to report details or support DJango with idea to work by own.
Hi. This behaviour has been unchanged since ManifestStaticFilesStorage was introduced in Django 1.7. You're welcome to make whatever adjustments you need in a subclass (or configure your webserver to route
styles.css?<HASH>
requests to the right file) but it's not something we can just change.You say "problematic" but don't explain that at all. Likely it's your set up but if you can narrow down a specific issue in Django we're happy to have a look.
Thanks