On Wed, Dec 1, 2010 at 3:55 PM, Mikhail Korobov <kmik...@googlemail.com> wrote: > Just for the record: I'm with Ivan here and think that > > from django.template.response import TemplateResponse > def my_view(request): > return TemplateResponse(request, 'foo.html') > > is worse than > > from django.shortcuts import render > def my_view(request): > return render(request, 'foo.html') > > I think that the cases where user should prefer 'render' returning > HttpResponse over 'render' returning TemplateResponse are rare so the > API by itself should suggest TemplateResponse. TemplateResponse is > more flexible and can provide a performance benefit (the template > rendering can be prevented in some cases). > > I don't see much value in adding 'render' shortcut that just use > RequestContext after TemplateResponse is introduced - one can still > use render_to_response if TemplateResponse is undesired and one > shouldn't use such 'render' in other cases. > > 'render' as alias for TemplateResponse seems fine for me: it is a > shortcut and it adds value by simplifying the API.
I'd argue it doesn't simplify anything. It saves you a grand total of 10 characters (plus a couple more on import), but at the cost of the added complexity of having two ways of doing *exactly* the same thing. There is also a loss of explicitness -- there's no doubting what TemplateResponse will return. On the other hand, there *is* value in adding a render() shortcut -- because there will be a subset of cases where a TemplateResponse isn't needed, but a HttpResponse with a RequestContext is. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.