マニュアルによると、それは可能なはずです
オブジェクト、データ ディクショナリ、またはその両方を指定して、脱水/水和サイクル全体で使用するバンドルを構築します。
だから私は Resource を使ってこれをまとめました
def get_list(self, request, **kwargs):
bundles = []
foo = {}
foo['bar'] = 1
bundle = self.build_bundle(data=foo, request=request)
bundles.append(self.full_dehydrate(bundle))
serialized = {}
serialized[self._meta.collection_name] = bundles
serialized = self.alter_list_data_to_serialize(request, serialized)
return self.create_response(request, serialized)
しかし、私がそれを通り過ぎていても、full_hydrate()
それは窒息します。bar
ここで何が欠けていますか?
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
77. return view_func(*args, **kwargs)
File "/home/dan/project/tastypie/resources.py" in wrapper
203. response = callback(request, *args, **kwargs)
File "/home/dan/project/tastypie/resources.py" in dispatch_list
445. return self.dispatch('list', request, **kwargs)
File "/home/dan/project/tastypie/resources.py" in dispatch
477. response = method(request, **kwargs)
File "/home/dan/project/resources/widgets.py" in get_list
188. base_bundle = self.build_bundle(request=request)
File "/home/dan/project/tastypie/resources.py" in build_bundle
704. obj = self._meta.object_class()
Exception Type: TypeError at /api/widget/fundperfyearly/
Exception Value: 'NoneType' object is not callable