Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DjangoFilterBackend' object has no attribute 'get_schema_operation_parameters' #6816

Closed
4 of 6 tasks
AlexIvanchyk opened this issue Jul 17, 2019 · 1 comment
Closed
4 of 6 tasks

Comments

@AlexIvanchyk
Copy link

Checklist

  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

  1. DRF version 3.10.0.
  2. Create simple view with DjangoFilterBackend from django_filters.rest_framework
from rest_framework import generics
from django_filters import rest_framework as filters

class SimpleView(generics.ListAPIView):
    serializer_class = SomeSerializer
    filter_backends = (filters.DjangoFilterBackend,)
  1. Run server and try generate OpenAPI schema(by view)

Expected behavior

Should work

Actual behavior

This causes a corresponding error:

Internal Server Error: /openapi
Traceback (most recent call last):
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/views.py", line 497, in dispatch
    response = self.handle_exception(exc)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/views.py", line 48, in handle_exception
    return super().handle_exception(exc)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/views.py", line 457, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/views.py", line 468, in raise_uncaught_exception
    raise exc
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/views.py", line 494, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/views.py", line 37, in get
    schema = self.schema_generator.get_schema(request, self.public)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/openapi.py", line 62, in get_schema
    paths = self.get_paths(None if public else request)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/openapi.py", line 49, in get_paths
    operation = view.schema.get_operation(path, method)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/openapi.py", line 96, in get_operation
    parameters += self._get_filter_parameters(path, method)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/rest_framework/schemas/openapi.py", line 185, in _get_filter_parameters
    parameters += filter_backend().get_schema_operation_parameters(self.view)
  File "/Users/alex/PycharmProjects/handiscover_api/venv/lib/python3.7/site-packages/django_filters/utils.py", line 61, in __getattr__
    return self.__getattribute__(name)
AttributeError: 'DjangoFilterBackend' object has no attribute 'get_schema_operation_parameters'
@carltongibson
Copy link
Collaborator

Please see carltongibson/django-filter#1086

pip install -U django-filter

(pip list --outdated is your friend here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants