Skip to content

'ViewSet' object has no attribute 'request' during Schema generation #4373

@Skorpyon

Description

@Skorpyon

I use get_queryset() and get_serializer_class() across almost all my apps.
Usually I follow a way from DRF documentation:

def get_serializer_class(self):
    if self.request.user.is_staff:
        return FullAccountSerializer
    return BasicAccountSerializer

Yesterday I update DRF version from from 3.3.3 to 3.4 and setup restframework-swagger.
It returns me: AttributeError " DriverVehiclesViewSet' object has no attribute 'request' "

.../python3.5/site-packages/rest_framework/schemas.py in get_api_endpoints
prefix=path_regex ...
.../python3.5/site-packages/rest_framework/schemas.py in get_api_endpoints
prefix=path_regex ...
.../python3.5/site-packages/rest_framework/schemas.py in get_api_endpoints
prefix=path_regex ...
.../python3.5/site-packages/rest_framework/schemas.py in get_api_endpoints
link = self.get_link(path, method, callback) ...
.../python3.5/site-packages/rest_framework/schemas.py in get_link
fields += self.get_serializer_fields(path, method, callback, view) ...
.../python3.5/site-packages/rest_framework/schemas.py in get_serializer_fields
serializer_class = view.get_serializer_class() ...
.../src/taxiback/api/v1/views/driver.py in get_serializer_class
if self.request.method in drf_permissions.SAFE_METHODS: ...

Can somebody explain me why I got it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy