#10120 closed (fixed)
Possible mistake? in "render_to_response()" Example / NO return value
| Reported by: | vl4dt | Owned by: | Kevin Kubasik |
|---|---|---|---|
| Component: | Documentation | Version: | 1.0 |
| Severity: | Keywords: | render_to_response possible mistake mispelling error missing return function value no kkmegapatch | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
render_to_response() - Example - No return value
Possible mistake
found at:
Django shortcut functions: render_to_response() - Example
First piece of code:
from django.shortcuts import render_to_response def my_view(request): # View code here... return render_to_response('myapp/index.html', {"foo": "bar"}, mimetype="application/xhtml+xml")
equivalent to:
from django.http import HttpResponse from django.template import Context, loader def my_view(request): # View code here... t = loader.get_template('myapp/template.html') c = Context({'foo': 'bar'}) r = HttpResponse(t.render(c), mimetype="application/xhtml+xml")
Possible mistake:
The second fragment does not "return" anything, or does return "r"?
Maybe this line at the end of the function is missing:
return r
or this line:
r = HttpResponse(t.render(c), mimetype="application/xhtml+xml")
was intended to be:
return HttpResponse(t.render(c), mimetype="application/xhtml+xml")
I am new to Python and Django so if I am just ignorant on Python please point why I am wrong.
Postdata:
Excelent framework and documentation, I come from Rails and am really impressed by the quality of Django and how complete and comprehensive the documentation is, keep doing that great work.
Excuse my bad english.
Attachments (1)
Change History (10)
comment:1 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
by , 17 years ago
| Attachment: | render.patch added |
|---|
comment:2 by , 17 years ago
| milestone: | post-1.0 |
|---|
comment:3 by , 17 years ago
| Has patch: | set |
|---|
comment:4 by , 17 years ago
| milestone: | → 1.1 |
|---|
comment:5 by , 17 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:6 by , 17 years ago
| Keywords: | kkmegapatch added |
|---|---|
| Owner: | changed from to |
comment:7 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Milestone post-1.0 deleted