Django-rest-framework: Crash in include_docs_urls when upgrading from 3.9 to 3.10

Created on 19 Jul 2019  ·  3Comments  ·  Source: encode/django-rest-framework

Checklist

  • [ ] I have verified that that issue exists against the master branch of Django REST framework.
  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] This is not a usage question. (Those should be directed to the discussion group instead.)
  • [x] 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.)
  • [x] 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

Use djangorestframework==3.10.0

In urls.py:

from django.urls import path
from rest_framework.documentation import include_docs_urls

urlpatterns = [
    path("docs/", include_docs_urls(title="Platinum API docs")),
]

Visit /docs/ in browser.

Expected behavior

No crash please.

Actual behavior

2019-07-19 11:41:21,446 [django.request] [ERROR] Internal Server Error: /docs/
Traceback (most recent call last):
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/views.py", line 497, in dispatch
    response = self.handle_exception(exc)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/schemas/views.py", line 48, in handle_exception
    return super().handle_exception(exc)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/views.py", line 457, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/views.py", line 468, in raise_uncaught_exception
    raise exc
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/schemas/views.py", line 37, in get
    schema = self.schema_generator.get_schema(request, self.public)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/schemas/coreapi.py", line 153, in get_schema
    links = self.get_links(None if public else request)
  File "/home/thnee/.pyenv/versions/lookatech-platinum/lib/python3.6/site-packages/rest_framework/schemas/coreapi.py", line 140, in get_links
    link = view.schema.get_link(path, method, base_url=self.url)
AttributeError: 'AutoSchema' object has no attribute 'get_link'
2019-07-19 11:41:21,449 [django.server] [ERROR] "GET /docs/ HTTP/1.1" 500 27

Most helpful comment

Duplicate of #6809.

See the 3.10 release notes on Continuing to use CoreAPI.

All 3 comments

Same problem with version 3.10.1. Downgrading to 3.9.4 solves the problem. All of these tests were done with coreapi 2.3.3 and django 2.2.3.

Duplicate of #6809.

See the 3.10 release notes on Continuing to use CoreAPI.

add the line in

project/settings.py

REST_FRAMEWORK = { ... 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' }

Was this page helpful?
0 / 5 - 0 ratings