I just want to method like get_list which can return list of objects not HttpResponse, and without format=json parameter.
I'm aware about getting data from resource through bundle like this:
resource = MyResource()
request_bundle = resource.build_bundle(request)
queryset = resource.obj_get_list(request_bundle)
bundles = []
for obj in queryset:
bundle = resource.build_bundle(obj=obj, request=request)
bundles.append(resource.full_dehydrate(bundle, for_list=True))
objects = [b.data for b in bundles]
get_list works fine, but I need generate my own response rendering template, and get_list require format=json in his parameters.
but it return all objects instead of 20
If you want to return 20 items.
queryset = resource.obj_get_list(request_bundle)[:20]
P/s: Thank you for the code is what i am looking for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.