Reputation: 4425
I keep getting the following errors:
Traceback (most recent call last):
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 217, in wrapper
response = callback(request, *args, **kwargs)
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 459, in dispatch_list
return self.dispatch('list', request, **kwargs)
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 491, in dispatch
response = method(request, **kwargs)
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 1299, in get_list
objects = self.obj_get_list(bundle=base_bundle, **self.remove_api_resource_names(kwargs))
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 2113, in obj_get_list
return self.authorized_read_list(objects, bundle)
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/resources.py", line 610, in authorized_read_list
auth_result = self._meta.authorization.read_list(object_list, bundle)
File "/srv/www/poka/app/env/main/lib/python2.7/site-packages/tastypie/authorization.py", line 151, in read_list
klass = self.base_checks(bundle.request, object_list.model)
AttributeError: 'list' object has no attribute 'model'
This happens when I am calling the following model:
class NewsResource(ModelResource):
class Meta:
queryset = News.objects.select_related('picture').all()
allowed_methods = ['get','patch']
include_resource_uri = False
include_absolute_url = False
authentication = ApiKeyAuthentication()
authorization = DjangoAuthorization()
Any ideas?
Upvotes: 0
Views: 4516
Reputation: 11162
As Hai vu said, your object has no model
attribute.
To help you understand your problem, you can use PDB to debug this. This is very simple to set. Just before the line responsible of the problem, write this in your code:
import pdb; pdb.set_trace()
It will freeze your server as this point in the code. Then in the shell, feel free to test things like :
list.model # will throw the same error
or
list.__dict__ # will show all the possible attributes that you can use with the list object
Upvotes: 1
Reputation: 40733
Here is an example to demonstrate your error:
>>> object_list = [1, 2, 3]
>>> object_list.model
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'model'
I suspect that object_list
in your case is a list and thus does not have attribute model
. Please check your code.
Upvotes: 1