I am trying to create a REST API, but I'm facing the below issue:
/tastypie/resources.py", line 1475, in get_object_list
return self._meta.queryset._clone()
AttributeError: 'NoneType' object has no attribute '_clone'
class ManageResource(ModelResource):
class Meta(ModelResource.Meta):
resource_name = 'resourceStatus'
detail_allowed_methods = ['get']
always_return_data = True
default_format = 'application/json'
def base_urls(self):
return [
url(r"^(?P<resource_name>%s)%s$" % (self._meta.resource_name,
trailing_slash()), self.wrap_view('dispatch_list'),
name="api_dispatch_list"),
url(r"^(?P<resource_name>%s)/(?P<request_id>[\w\d_.-]+)%s$"
% (self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
def get_detail(self, request, **kwargs):
id = int(kwargs["request_id"])
return self._get_response(request, self.obj_get(request=request,id=id))
@obj_wrapper
def obj_get(self, request, id):
result = Helper().status(id=id)
return {"info":{"start_time":result.get("start_time"),\
"end_time":result.get("end_time"),\
"status":result.get("status"),\
"messages":result.get("messages")}}
I haven't set queryset in the meta class, since I pull data from a file or some kind of static resource.
Add queryset
field to your resource's Meta
. If you are not using the standard QuerySet
, override get_object_list
method.