profile
viewpoint

Ask questionsUpgrading to DRF 3.10.0 breaks settings

After upgrading to DRF == 3.10.0 following error message appears when trying to run server

ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator' from 're
st_framework.schemas.generators' (/Users/...../.local/share/virtualenvs/......./lib/python3.7/site-packages/rest_framework/schemas/generators.py).

Apparently, SchemaGenerator has been renamed to BaseSchemaGenerator, with some changes.

Adding the following lines to SWAGGER_SETTINGS in settings.py seems to work.

SWAGGER_SETTINGS = {
    "DEFAULT_GENERATOR_CLASS": "rest_framework.schemas.generators.BaseSchemaGenerator",
....

axnsan12/drf-yasg

Answer questions nourwolf

I don't think changing the setting is enough. SchemaGenerator wasn't just renamed. Using the BaseSchemaGenerator results in an error when opening the docs.

useful!
source:https://uonfu.com/
Github User Rank List