#23506: How to reference static files outside of the template -------------------------------------+-------------------- Reporter: thenewguy | Owner: nobody Type: Uncategorized | Status: new Component: contrib.staticfiles | Version: 1.7 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------- There should be a function like `django.contrib.staticfiles.templatetags.staticfiles.static` that is safe to use outside of a template. When it cannot find a static file, it should probably be configured to return a url pointing at a view that logs the file is missing and returns a 404.
I just discovered that I took down an environment with one call to `static` from `django.contrib.staticfiles.templatetags.staticfiles`. {{{ from django.contrib.staticfiles.templatetags.staticfiles import static class FooForm(ModelForm): class Media: js = ( static("foo.js"), ) }}} `foo.js` didn't get put in place. So what is the correct way to reference a static file outside of a template keeping something like `django.contrib.staticfiles.storage.ManifestStaticFilesStorage` in mind? -- Ticket URL: <https://code.djangoproject.com/ticket/23506> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.f1966dff716cfd0e8218dbb5827230f1%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.