Django-Tastypie:你如何在Bundle中访问(Http)请求对象? [英] Django-Tastypie: How Do You Access (Http)request object in the Bundle?

查看:135
本文介绍了Django-Tastypie:你如何在Bundle中访问(Http)请求对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要访问我的资源的脱水
方法中的HttpRequest对象。

I need to access the HttpRequest object in my Resource's dehydrate method.

在文档中,它显示了bundle.request是一个有效的属性(resource.html页面中的
)。当我尝试添加到我的代码,我得到一个
的错误,声称Bundle的对象没有属性'请求'。
什么给了?

In the docs, it shows that bundle.request is a valid attribute (it's in the resources.html page). When I try to add it to my code, I get an error claiming that Bundle' object has no attribute 'request'. What gives?

推荐答案

我刚刚遇到同样的问题,但在这里找到了正确的答案:
http://groups.google.com/group / django-tastypie / tree / browse_frm / thread / 801f44af3f2dbe7b / a36f303380eacf96

I just had the same problem, but found the correct answer over here: http://groups.google.com/group/django-tastypie/tree/browse_frm/thread/801f44af3f2dbe7b/a36f303380eacf96

似乎django-tasty-pie版本0.9.9没有此属性但是版本0.9.10确实如此!

it seems django-tasty-pie version 0.9.9 didn't have this attribute but version 0.9.10 does!

所以如果你使用buildout,看看buildout.cfg
下的版本:
搜索 django-tastypie = 0.9.9

so if you use buildout, look in to buildout.cfg under versions: search for django-tastypie = 0.9.9

删除这个,看看你的安装选择或替换它:

remove this one and see what your install picks or replace it with:

django-tastypie = 0.9.10

我还有这个问题,所以打开一个新的链接,看看:

I still have this problem, so opened a new link, see:

django-tastypie:无法访问bund.request在脱水(自我,束缚)

在上面的问题中我发现,使用0.9.10是不够的,版本1.0.0 beta应该做三角形。 。

in the question above I found out, that using 0.9.10 is not enough, version 1.0.0 beta should do the tric..

这篇关于Django-Tastypie:你如何在Bundle中访问(Http)请求对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆