#19582 closed New feature (fixed)
Add tutorial on static files
Reported by: | James Pic | Owned by: | Tim Graham |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | docs, static files, sprint2013 |
Cc: | James Pic, reinout@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | no |
Description
Maybe it's just me, but I've seen so many users confused by how django static files work.
Users trying to stuff their project-specific staticfiles into STATIC_ROOT for example, instead of adding a path in STATICFILES_DIRS.
A tutorial for static files could help many users.
Attachments (2)
Change History (26)
comment:1 by , 12 years ago
Easy pickings: | set |
---|---|
Keywords: | docs static files added |
Needs documentation: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
Version: | 1.4 → master |
comment:2 by , 12 years ago
Zed Shaw has provided a detailed teardown/rant on what is wrong with the current docs, and how to improve them. Summarizing, It looks like the confusion stems from three sources:
- Understanding what staticfiles is actually trying to do
- Ordering of information - the howto talks about production needs before development needs
- Clarity over the role played by various settings.
comment:3 by , 12 years ago
I took a stab at rewriting the first part of the static files howto (rendered). This was based on, for the first time in literally years, trying to set up static files from scratch and finally wrapping my head around it.
For those coming at staticfiles with the expectation of "put files in this folder, they get served at this URL", the app-specific static files idea is confusing. This rewrite makes it more clear what's necessary to get that outcome, and explain why the process is the way it is.
comment:4 by , 12 years ago
Has patch: | set |
---|---|
Needs documentation: | unset |
comment:5 by , 12 years ago
Cc: | added |
---|
I have worked on this ticket (based on Alec's work and Zed's remarks) in a branch: https://github.com/jpic/django/blob/ticket_19582/docs/howto/static-files.txt
comment:6 by , 12 years ago
Cc: | added |
---|
comment:7 by , 12 years ago
A quick discussion about staticfiles from Zed Shaw: https://twitter.com/jezdez/statuses/291608100564242432
comment:8 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Note: we're sprinting on this in Utrecht at the "Dutch winter sprint" 23/24 feb 2013.
comment:9 by , 12 years ago
Keywords: | sprint2013 added |
---|
by , 12 years ago
Attachment: | proposal_1.rst added |
---|
Proposal for the tutorial06, based on Jannis suggestion to kind of follow the structure of the tutorial about templates (project-specific override first, app templates next)
by , 12 years ago
Attachment: | proposal_0.rst added |
---|
Proposal for tutorial06 about staticfiles: with smaller steps but not following the exact same pedagogy used to teach template file management
comment:10 by , 12 years ago
On which structure should we base tutorial06 about staticfiles ? proposal_1.rst or proposal_0.rst ?
comment:11 by , 12 years ago
Proposal 0, as it introduces app level static files earlier. I just talked with Aymeric about it and we decided it would be best to move more toward pushing the idea of apps in the tutorial in general, including the part where we point to TEMPLATES_DIRS
. This would be another ticket entirely of course.
comment:13 by , 12 years ago
After talking with Aymeric, we decided the following plan for tutorial06:
- Using the AppDirectoriesFinder: demonstrates how to use polls/static/polls/style.css with {% static 'polls/style.css' %},
- Relating static files: a simple demonstration of adding a css background image, just to have an opportunity of warning the user that he should not hardcode absolute paths.
comment:14 by , 12 years ago
Pull request: https://github.com/django/django/pull/795
Rendered version: http://yourlabs.org/site_media/django/docs/_build/html/intro/tutorial06.html
comment:15 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:17 by , 12 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
This isn't quite RFC, I've left some comments on the pull request.
comment:18 by , 12 years ago
This should be merged simultaneously with #19897 as some bits are moved from the howto to this new tutorial.
comment:19 by , 12 years ago
Owner: | changed from | to
---|
I'm reviewing this and will merge it when finished.
comment:20 by , 12 years ago
If you want me (or probably jpic) to do some squish-commits-together work or something like that, just say so :-)
comment:21 by , 12 years ago
Updated pull request (includes #19897): https://github.com/django/django/pull/889
rendered: http://techytim.com/django/19897/intro/tutorial06.html
comment:22 by , 12 years ago
Type: | Cleanup/optimization → New feature |
---|
comment:23 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
It's not just you. :)
Django docs contain two pages about static files:
https://docs.djangoproject.com/en/dev/howto/static-files/
https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
The first one is hard to understand but does the job and acts as a kind of tutorial. In my opinion, we could re-write this information but make it more easy to understand.
If you are willing to make a contribution to Django, you are welcome to do so and apply a patch. I'll set easy pickings.