﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10120	"Possible mistake? in ""render_to_response()"" Example / NO return value"	vl4dt	Kevin Kubasik	"= render_to_response() - Example - No return value =
== Possible mistake ==
found at:
[http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response Django shortcut functions: render_to_response() - Example]

First piece of code:
{{{
#!python
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:
{{{
#!python
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:
{{{
#!python
    return r
}}}

or this line:
{{{
#!python
    r = HttpResponse(t.render(c),
        mimetype=""application/xhtml+xml"")
}}}

was intended to be:
{{{
#!python
    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.


"		closed	Documentation	1.0		fixed	render_to_response possible mistake mispelling error missing return function value no kkmegapatch		Ready for checkin	1	0	0	0	0	0
