Using Django.test.client to check template vars

Posted by scott on Stack Overflow See other posts from Stack Overflow or by scott
Published on 2010-05-29T22:39:25Z Indexed on 2010/05/29 22:42 UTC
Read the original article Hit count: 192

Filed under:
|
|

I've got a view that I'm trying to test with the Client object. Can I get to the variables I injected into the render_to_response of my view?

Example View:

def myView(request):

    if request.method == "POST":
        # do the search
        return render_to_response('search.html',{'results':results},context_instance=RequestContext(request))
    else:
        return render_to_response('search.html',context_instance=RequestContext(request)

Test:

c = Client()

response = c.post('/school/search/', {'keyword':'beagles'})
# how do I get to the 'results' variable??

© Stack Overflow or respective owner

Related posts about django

Related posts about client