Django ContextList键

Tre*_*ent 3 python django django-testing

有没有办法在运行测试工具时获取返回的ContextList对象的键?

如果我有:

return render_to_response('x.html', 
                              {
                               'one' : 1,
                               'two' : 2,
                               'three' : 3
                               },
                              context_instance=RequestContext(request)) 
Run Code Online (Sandbox Code Playgroud)

有没有办法循环键一,二,三?

Piz*_*her 6

keys = []
for subcontext in response.context:
  for d in subcontext.dicts:
    for k in d.keys():
      if k not in keys:
        keys.append(k)

print keys
Run Code Online (Sandbox Code Playgroud)