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
- Writing more views introduces
polls.views.detail
code that is testable withrunserver
:
def detail(request, poll_id): return HttpResponse("You're looking at poll %s." % poll_id)
- 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
)
- Then, this view code changes in A shortcut: get_object_or_404.
- 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 , 12 years ago
Cc: | added |
---|---|
Easy pickings: | set |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
I might change
"working, just:"
to
"working, a file containing just:"
But otherwise - yes, you can't cover everything simultaneously.
comment:6 by , 12 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
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.
Well, below [1] it does say:
What's your suggestion for how to improve it?