Opened 12 years ago

Closed 12 years ago

#19889 closed Cleanup/optimization (needsinfo)

Tutorial03 makes you refactor code that you cannot run

Reported by: James Pic Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: James Pic Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

  1. Writing more views introduces polls.views.detail code that is testable with runserver:
    def detail(request, poll_id):
        return HttpResponse("You're looking at poll %s." % poll_id)
  1. Then, Raising 404 error introduces a new version of this view:
def detail(request, poll_id):
    try:
        poll = Poll.objects.get(pk=poll_id)
    except Poll.DoesNotExist:
        raise Http404
    return render(request, 'polls/detail.html', {'poll': poll})

(Which you cannot test yet because you don't have polls/detail.html)

  1. Then, this view code changes in A shortcut: get_object_or_404.
  1. Then, and only then, the tutorial makes you create polls/details.html in Use the template system.

I think it's a problem that you code something in step 2., change it in step 3., but are able to test it only after step 4. Shouldn't the app be run-able at every step ?

Change History (6)

comment:1 by James Pic, 12 years ago

Cc: James Pic added
Easy pickings: set
Type: UncategorizedCleanup/optimization

comment:2 by Tim Graham, 12 years ago

Well, below [1] it does say:

We’ll discuss what you could put in that polls/detail.html template a bit later, but if you’d like to quickly get the above example working, just:

{{ poll }}

will get you started for now.

What's your suggestion for how to improve it?

comment:3 by Preston Holmes, 12 years ago

I might change

"working, just:"

to

"working, a file containing just:"

But otherwise - yes, you can't cover everything simultaneously.

comment:4 by Preston Holmes <preston@…>, 12 years ago

In f60dd6f55dcd646dcec4f7f8b2cc73af985ccba3:

[1.5.x] Made a small clarification in tutorial.

refs #19889

comment:5 by Preston Holmes <preston@…>, 12 years ago

In 17a28b39a8d77997f83ecd94ebcff7b198b8cb05:

Made a small clarification in tutorial.

refs #19889

comment:6 by Preston Holmes, 12 years ago

Resolution: needsinfo
Status: newclosed

I made the small clarification - going to close as needs info, if the ticket author can provide some other concrete suggestions for improvement, by all means - please reopen.

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