drf_openapi icon indicating copy to clipboard operation
drf_openapi copied to clipboard

ImportError: No module named generators

Open ju5t opened this issue 8 years ago • 2 comments

  • DRF OpenAPI version: 1.3.0
  • DRF version: 3.6.4
  • Python version: 2.7
  • Operating System: Ubuntu 16.04 (Docker) and MacOS

Description

I tried to add drf_openapi to an existing project.

What I Did

I have added drf-openapi==1.3.0 to my requirements.txt and installed it. I've added 'drf_openapi', to INSTALLED_APPS and url(r'^/docs/', include('drf_openapi.urls')) to the urlpatterns.

When starting the Docker image (or just runserver locally) this results in the following error:

 File "/usr/local/lib/python2.7/dist-packages/drf_openapi/views.py", line 7, in <module>
   from drf_openapi.entities import OpenApiSchemaGenerator
 File "/usr/local/lib/python2.7/dist-packages/drf_openapi/entities.py", line 16, in <module>
   from rest_framework.schemas.generators import insert_into, distribute_links, LinkNode
ImportError: No module named generators

If it makes any difference our DEFAULT_VERSIONING_CLASS is set to AcceptHeaderVersioning.

REST_FRAMEWORK = {
    'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning',
    'DEFAULT_VERSION': API_VERSION,
}

Obviously I'm missing something out in the open here. The default documentation in DRF does work for us.

ju5t avatar Feb 10 '18 09:02 ju5t

Apparently DRF 3.6.4 isn't supported anymore. I've upgraded to 3.7.7 and that starts the application but fails to render any pages. From the looks of it because AcceptHeaderVersioning is not playing along.

NoReverseMatch: Reverse for 'api_schema' with keyword arguments '{u'version': u'1.0.0'}' not found. 1 pattern(s) tried: ['docs/schema/$']

ju5t avatar Feb 10 '18 14:02 ju5t

I have the same problem.

volodchenkov avatar Mar 13 '18 18:03 volodchenkov