When I try to issue a GET to my model (using TastyPie
), I get the following traceback error:
File "/Library/Python/2.7/site-packages/tastypie/resources.py", line
2141, in get_object_list
return self._meta.queryset._clone()
AttributeError: 'NoneType' object has no attribute '_clone'
Below is my resources.py
file for the relevant Model.
from tastypie.resources import ModelResource
from swtr.models import Com
class ComResource(ModelResource):
class Meta:
query_set = Com.objects.all()
resource_name = 'com'
object_class = none
I'm particularly confused given that Com.objects.all()
returns at least one record that I created and saved within the python shell. So I'm not sure why the queryset is being returned as a NoneType
.
You have misspelled some fields in your ComResource
's Meta
class.
Try renaming query_set
to queryset
and give object_class
a value of None
, not none
:
from tastypie.resources import ModelResource
from swtr.models import Com
class ComResource(ModelResource):
class Meta:
queryset = Com.objects.all()
# __^
resource_name = 'com'
object_class = None
# _____________^