Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20482 closed Cleanup/optimization (fixed)

File name/type Labels for Code for Tutorial Pt 3 - Write views that actually do something

Reported by: diek@… 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)

20482_docs-tutorial03_index-view-py.diff (533 bytes ) - added by Elena Williams 12 years ago.
Adding 7 words to describe which file the code goes in.

Download all attachments as: .zip

Change History (6)

comment:1 by Elena Williams, 12 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

by Elena Williams, 12 years ago

Adding 7 words to describe which file the code goes in.

comment:2 by Elena Williams, 12 years ago

Has patch: set

comment:3 by Baptiste Mispelon, 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 Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 9e65bd33db5d211e114f6193ec2f70ccd4947e72:

Fixed #20482 - Added a file reference in tutorial 3.

Thanks diek@ for the suggestion.

comment:5 by Tim Graham <timograham@…>, 12 years ago

In 7df9c2bc7d6226b9f9ca7dd3da3f34c4b0482b06:

[1.5.x] Fixed #20482 - Added a file reference in tutorial 3.

Thanks diek@ for the suggestion.

Backport of 9e65bd33db from master

Note: See TracTickets for help on using tickets.
Back to Top