#25553: Add lazy version of admin_static's static
-------------------------------+--------------------------------------
Reporter: dsanders11 | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by dsanders11):
I could see the need to execute a management command before collectstatic,
such as `manage.py migrate --dry-run` to see which migrations will be
applied.
However, the bigger concern is that collectstatic is itself a management
command so it can't run either.
If there's a situation where a models.py file imports a file which uses
the non-lazy static, this causes the management command (including
collectstatic) to fail since it is unable to find the path to the
collected static since it hasn't been collected yet.
Currently the static templatetag in admin_static contains fallback logic
if django.contrib.staticfiles isn't in INSTALLED_APPS. This is useful for
thirdparty apps which can't rely on it being installed. While Django only
uses it in a few admin files it is useful anywhere that uses
[https://docs.djangoproject.com/en/1.8/topics/forms/media/ form assets] to
get this same fallback logic. Using it for regular forms increases the
odds this type of scenario will occur where it is evaluated during model
collection in the app registry.
The docs don't really touch on using the static templatetag to ensure form
assets have the correct filename, but it's important for having them work
well with CachedStaticFilesStorage or ManifestStaticFilesStorage out of
the box, otherwise they use unhashed filenames and may get cached (CDN or
browser) without the developer realizing.
Long winded, but just trying to make the use case clear.
--
Ticket URL: <https://code.djangoproject.com/ticket/25553#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.abf22196180436f9759cb49867bd314a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.