Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django tastypie:无法访问dehydrate中的bundle.request(self,bundle)_Django_Tastypie - Fatal编程技术网

django tastypie:无法访问dehydrate中的bundle.request(self,bundle)

django tastypie:无法访问dehydrate中的bundle.request(self,bundle),django,tastypie,Django,Tastypie,我发现有人也有同样的问题,但对他的安慰对我不起作用: 看见 我正在尝试应用以下建议的解决方法: 在我的资源文件(api.py)中生成以下代码: 我得到一个错误: { error_message: "'Bundle' object has no attribute 'request'", traceback: "Traceback (most recent call last): File "/home/michel/django/sites/regelwater/eggs/django

我发现有人也有同样的问题,但对他的安慰对我不起作用: 看见

我正在尝试应用以下建议的解决方法:

在我的资源文件(api.py)中生成以下代码:

我得到一个错误:

{
error_message: "'Bundle' object has no attribute 'request'",
traceback: "Traceback (most recent call last):

  File "/home/michel/django/sites/regelwater/eggs/django_tastypie-0.9.10-py2.6.egg/tastypie/resources.py", line 178, in wrapper
    response = callback(request, *args, **kwargs)

  File "/home/michel/django/sites/regelwater/eggs/django_tastypie-0.9.10-py2.6.egg/tastypie/resources.py", line 379, in dispatch_list
    return self.dispatch('list', request, **kwargs)

  File "/home/michel/django/sites/regelwater/eggs/django_tastypie-0.9.10-py2.6.egg/tastypie/resources.py", line 409, in dispatch
    response = method(request, **kwargs)

  File "/home/michel/django/sites/regelwater/eggs/django_tastypie-0.9.10-py2.6.egg/tastypie/resources.py", line 987, in get_list
    to_be_serialized['objects'] = [self.full_dehydrate(obj=obj) for obj in to_be_serialized['objects']]

  File "/home/michel/django/sites/regelwater/eggs/django_tastypie-0.9.10-py2.6.egg/tastypie/resources.py", line 638, in full_dehydrate
    bundle = self.dehydrate(bundle)

  File "/home/michel/django/sites/regelwater/reservoir/api.py", line 71, in dehydrate
    if bundle.request:

AttributeError: 'Bundle' object has no attribute 'request'
"
}

如果您是从pypi安装的,那么您可能正在运行Tastypie9.10。pypi版本中的Bundle对象

如果您升级到git版本的django tastypie master并使用它,那么问题应该得到解决

pip uninstall django-tastypie 
pip install -e git+https://github.com/toastdriven/django-tastypie.git#egg=django-tastypie

答案是Thanx,但是:由于在一台服务器上有几个独立的Web应用程序,我不希望或至少在服务器上安装尽可能少的应用程序。因此,我使用buildout。通过buildout,我找到了pypi。顺便说一句,这很难知道,因为在其他回答中,他们说我需要9.10而不是9.10,所以我很高兴看到9.10版在pypi上出现,并且在那之后非常失望。至少现在我知道为什么了。(这就是为什么我投了更高的票)9.10意味着0.9.10。。。到今天为止,最新的tastype是0.10.0。
pip uninstall django-tastypie 
pip install -e git+https://github.com/toastdriven/django-tastypie.git#egg=django-tastypie