hi developer,
i meet a problem. for some reason, i overwriter DjangoRestResponsePagination for realizing a custom response 。
this class path is project_path/libs/pagination
then i add this class for django settings file.
`REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
SWAGGER_SETTINGS = {
"DEFAULT_INFO": "config.urls.info",
"DEFAULT_PAGINATOR_INSPECTORS": [
"libs.pagination.RestResponsePagination",
"drf_yasg.inspectors.CoreAPICompatInspector",
],
} last, i try to import my custom paginator_inspector in python shell
from libs.pagination import RestResponsePagination
`
but the error is occuring.
ImportError: Could not import 'libs.pagination.RestResponsePagination' for API setting 'DEFAULT_PAGINATOR_INSPECTORS'. ImportError: Module "libs.pagination" does not define a "RestResponsePagination" attribute/class.
my question is why occur this error.
i try to some method,when i notes "from drf_yasg.inspectors import DjangoRestResponsePagination", the question is solved。
thanks reply
hi developer, i meet a problem. for some reason, i overwriter DjangoRestResponsePagination for realizing a custom response 。
this class path is project_path/libs/pagination then i add this class for django settings file. `REST_FRAMEWORK = { "DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
"DEFAULT_RENDERER_CLASSES": ["djangorestframework_camel_case.render.CamelCaseJSONRenderer"],
}
SWAGGER_SETTINGS = { "DEFAULT_INFO": "config.urls.info", "DEFAULT_PAGINATOR_INSPECTORS": [ "libs.pagination.RestResponsePagination", "drf_yasg.inspectors.CoreAPICompatInspector", ], }
last, i try to import my custom paginator_inspector in python shell
from libs.pagination import RestResponsePagination ` but the error is occuring. ImportError: Could not import 'libs.pagination.RestResponsePagination' for API setting 'DEFAULT_PAGINATOR_INSPECTORS'. ImportError: Module "libs.pagination" does not define a "RestResponsePagination" attribute/class.my question is why occur this error.
i try to some method,when i notes "from drf_yasg.inspectors import DjangoRestResponsePagination", the question is solved。 thanks reply