Skip to content

DjangoAuthorization does not work! #89

@nim4n

Description

@nim4n

I have some problem in using DjangoAuthorization , when I use this in my resource I get this error:

{"error_message": "'QuerySet' object has no attribute 'model'", "traceback": "Traceback (most recent call last):\n\n File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line 201, in wrapper\n response =
callback(request, _args, *_kwargs)\n\n File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line 432, in dispatch_list\n return self.dispatch('list', request, *_kwargs)\n\n File "/usr/local/lib/python2.7/dist-
packages/tastypie_mongoengine/resources.py", line 374, in dispatch\n return super(MongoEngineResource, self).dispatch(request_type, request, *_kwargs)\n\n File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line
464, in dispatch\n response = method(request, *_kwargs)\n\n File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line 1286, in get_list\n objects = self.obj_get_list(bundle=base_bundle,
*_self.remove_api_resource_names(kwargs))\n\n File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line 2068, in obj_get_list\n return self.authorized_read_list(objects, bundle)\n\n File
"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py", line 583, in authorized_read_list\n auth_result = self._meta.authorization.read_list(object_list, bundle)\n\n File "/usr/local/lib/python2.7/dist-
packages/tastypie/authorization.py", line 152, in read_list\n klass = self.base_checks(bundle.request, object_list.model)\n\nAttributeError: 'QuerySet' object has no attribute 'model'\n"}

but without using this It works fine, am I missed some thing? my resource is:
'''
class MainUserResource(resources.MongoEngineResource):
enduser = fields.ToOneField('interface.api.EndUserResource', 'enduser', full=False, null=True, blank=True)

    class Meta:
        queryset = User.objects.all()
        allowed_methods = ['get', 'post', 'put', 'delete']
        resource_name = 'main_user'
        fields = ['username', 'first_name', 'last_name', 'email']
        authorization = DjangoAuthorization()
        authentication = MultiAuthentication(BasicAuthentication(), SessionAuthentication())
        always_return_data = True
        list_allowed_methods = ['get', 'post', 'put', 'delete']
        filtering = {
            "username": ALL,
            "id": ALL,
            "enduser": ALL,
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions