Opened 11 years ago
Closed 3 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 , 11 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 , 3 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
staticwhich takes a path and urljoins it with the static prefixSTATIC_URL. Ifdjango.contrib.staticfilesis installed, the tag uses theurl()method of theSTATICFILES_STORAGEinstead.
comment:4 by , 3 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.txtwe already have this sentence:
The builtin template tag
staticwhich takes a path and urljoins it with the static prefixSTATIC_URL. Ifdjango.contrib.staticfilesis installed, the tag uses theurl()method of theSTATICFILES_STORAGEinstead.
Agreed, this has already been documented in cf546e11ac76c8dec527e39ff8ce8249a195ab42.
For this it would be helpful to point to
docs/howto/custom-file-storage.txtwhich lists the usual methods for storage classes. For example,staticfiles_storage.url('foo.js')works to get URL.