In my use of TemplateResponse in a real project, we encountered two
gotchas that I can think of off the top of my head:

1. You need to explicitly bake the response if you are testing using
assertContains
2. You need to explicitly bake the response before the
contrib.messages middleware

On Oct 23, 1:32 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Fri, Oct 22, 2010 at 7:32 PM, Mikhail Korobov <kmik...@googlemail.com> 
> wrote:
> > Russell's comments were helpful in discovering the edge case.
> > _set_content behaves differently for baked and non-baked responses:
>
> > response = render(request, Template('foo'))
> > response.content = 'bar'
> > print response.content    # 'foo'
> > response.content = 'baz'
> > print response.content    # 'baz'
>
> > This is confusing so I think responses should be marked as baked in
> > _set_content, not in force_bake.
>
> > The patch that should resolve this concern and Russell's concerns
> > regarding the tests:http://bitbucket.org/kmike/django/changeset/00f8be464749
>
> > I'll take a look at docs and generic views integration later.
>
> > Should new generic views return TemplateResponse by default?
>
> I would have thought so. Is there a compelling reason why CBV's
> shouldn't return a TemplateResponse?
>
> 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.

Reply via email to