Code

Opened 14 months ago

Closed 14 months ago

Last modified 14 months 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 14 months ago.
Adding 7 words to describe which file the code goes in.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 14 months ago by elena

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 14 months ago by elena

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

comment:2 Changed 14 months ago by elena

  • Has patch set

comment:3 Changed 14 months ago by bmispelon

  • 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 Changed 14 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 9e65bd33db5d211e114f6193ec2f70ccd4947e72:

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

Thanks diek@ for the suggestion.

comment:5 Changed 14 months ago by Tim Graham <timograham@…>

In 7df9c2bc7d6226b9f9ca7dd3da3f34c4b0482b06:

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

Thanks diek@ for the suggestion.

Backport of 9e65bd33db from master

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.