How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django python python

How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django


It worked for me, When I added below into Settings.py

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


As mentioned by @vctrd, this error may be due to CoreAPI support being deprecated in favor of OpenAPI since DRF 3.10:

Since we first introduced schema support in Django REST Framework 3.5,OpenAPI has emerged as the widely adopted standard for modeling WebAPIs.

This release begins the deprecation process for the CoreAPI basedschema generation, and introduces OpenAPI schema generation in itsplace.

You'll still be able to keep using CoreAPI schemas, API docs, andclient for the foreseeable future. We'll aim to ensure that theCoreAPI schema generator remains available as a third party package,even once it has eventually been removed from REST framework,scheduled for version 3.12.

As such, the generation of API schemas seems to have been made more convenient in the recent DRF versions if you use OpenAPI instead of Core API. The documentation of DRF OpenAPI schema generation can be found at: https://www.django-rest-framework.org/api-guide/schemas/

But if it is desirable to use Core API instead for whatever reason, @Omkar's answer will be the solution.