URLは次の例で上書きされています。 http://localhost:8000/api/v1/entry/1234/1233/?format=jsonのようなものを渡すと、self.create_response(request、data)を実行すると、ラップビューにパラメータが渡されます。ブラウザはVIEWを使ってシリアル化されたデータを返す方法は?
ブラウザで0x2e27a50で
api.Entryオブジェクト、フィールドがシリアライズされ得ることはありません: 注:私はこの段階でModelResourceを必要といけません。カスタムビューdispatch_dataをobj_getやget_object_listのようなデータを返すようにするにはどうしたらいいですか?次は、コードの問題部分です:
#Object class Class Entry(object) name = '' #Resource class class EntryResource(Resource): name = fields.CharField(attribute = 'name') class Meta: resource_name = 'entry' object_class = Entry include_resource_uri = False authentication = Authentication() authorization = Authorization() serializer = Serializer() def override_urls(self): return [url(r"^(?P<resource_name>%s)/(?P<p1>[\d]{4})/(?P<p2>[\d]{4})%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_data'),name='api_dispatch_data'),] def dispatch_data(self, request, **kwargs): p1 = kwargs['p1'] #params can be retrieved here p1 = kwargs['p2'] info = Entry() info.name = p1 #just example response = {1:info} return info.values() #Above results in ERROR, it will say Entry object has no attribute 'has_header' #changing to self.create_response(request, info) will not serialize the fields #urls.py api = Api(api_name='v1') api.register(EntryResource()) urlpatterns = patterns('', url(r'^api/', include(api.urls)), )