[英]How to get dictionary of RequestContext imported from django.template
I have the following code in my django project. 我的django项目中有以下代码。
ctxt = RequestContext(request, {
'power': power,
'attack': attack,
'defense': defense,
})
Now I want get this dictionary like below through ctxt
现在我希望通过ctxt
获得如下的字典
{
'power': power,
'attack': attack,
'defense': defense,
}
I tried ctxt.dicts
, but this contains too many items. 我试过ctxt.dicts
,但这包含太多项目。 So I see into the source code, and find these code in class RequestContext(Context):
所以我看到源代码,并在class RequestContext(Context):
找到这些代码class RequestContext(Context):
for processor in get_standard_processors() + processors:
self.update(processor(request))
which I think bring in the other items. 我想其他项目。
So how can I get that? 那我该怎么办呢?
Btw, if you want to know why I want to do this, you can see this question I asked before. 顺便说一句,如果你想知道我为什么要这样做,你可以看到我之前问过的这个问题。
How can I get a rewritten render_to_response to get a json in django with the least changes to the whole project 如何获得重写的render_to_response来获取django中的json,对整个项目的更改最少
ctxt.dict是一个字典堆栈,所以你只需要:
ctxt.dict[0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.