Opened 10 years ago
Closed 2 years ago
#23563 closed Cleanup/optimization (fixed)
Make `staticfiles_storage` a public API
Reported by: | Aymeric Augustin | Owned by: | Pablo Montepagano |
---|---|---|---|
Component: | Documentation | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
This is a follow-up ticket to #23506, focused on the part of the problem I believe we need to solve.
Django should provide a way to obtain the URL of static files other than the {% static %}
template tag. I haven't found one in the docs.
I think the easiest solution is to make django.contrib.staticfiles.storage.staticfiles_storage
a public API and document that it implements the file storage API, especially the url method.
Change History (4)
comment:1 by , 10 years ago
Component: | contrib.staticfiles → Documentation |
---|---|
Needs documentation: | unset |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 3 years ago
Easy pickings: | set |
---|
follow-up: 4 comment:3 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I don't believe there's much improvement to be made here. In the section "Other Helpers" of docs/ref/contrib/staticfiles.txt
we already have this sentence:
The builtin template tag
static
which takes a path and urljoins it with the static prefixSTATIC_URL
. Ifdjango.contrib.staticfiles
is installed, the tag uses theurl()
method of theSTATICFILES_STORAGE
instead.
comment:4 by , 2 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Replying to Pablo Montepagano:
I don't believe there's much improvement to be made here. In the section "Other Helpers" of
docs/ref/contrib/staticfiles.txt
we already have this sentence:
The builtin template tag
static
which takes a path and urljoins it with the static prefixSTATIC_URL
. Ifdjango.contrib.staticfiles
is installed, the tag uses theurl()
method of theSTATICFILES_STORAGE
instead.
Agreed, this has already been documented in cf546e11ac76c8dec527e39ff8ce8249a195ab42.
For this it would be helpful to point to
docs/howto/custom-file-storage.txt
which lists the usual methods for storage classes. For example,staticfiles_storage.url('foo.js')
works to get URL.