#20482 closed Cleanup/optimization (fixed)
File name/type Labels for Code for Tutorial Pt 3 - Write views that actually do something
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | no |
Description
I am following along the tutorials, and they are written well overall but one concept has stopped me in my tracks. You have sections of code, and in most cases it is perfectly clear where the code belongs. In Pt 3 - "Write views that actually do something", after I created the templates/polls/index.html, the next segment of code and where it goes is not clear.
"Now let’s use that html template in our index view:
from django.http import HttpResponse
from django.template import Context, loader
from polls.models import Poll
def index(request):
latest_poll_list = Poll.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(template.render(context))"
I have no idea where that code would go, other than it is a view.
I think a label for code segments, with filename would help those of us starting out... a lot.
Thank you,
Derrick
Attachments (1)
Change History (6)
comment:1 by , 12 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 12 years ago
Attachment: | 20482_docs-tutorial03_index-view-py.diff added |
---|
comment:2 by , 12 years ago
Has patch: | set |
---|
comment:3 by , 12 years ago
Patch needs improvement: | set |
---|
Hi,
I think the proposed patch introduces some issues.
It makes it sound as if we can just replace the whole views.py
file with the given example when it's not actually the case (other views have been created in the previous section).
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Adding 7 words to describe which file the code goes in.