Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

AttributeError at /swagger/ 'NoneType' object has no attribute 'title' #806

Open
farshadff opened this issue Jun 20, 2019 · 0 comments
Open

Comments

@farshadff
Copy link

i am using this package rest framework and its working fine and i installed the packge and added that to installed packages and here is what i changed in my url.py :


 from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
from django.shortcuts import redirect
from tutorial.quickstart import views
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)

SchemaView = get_schema_view(
    openapi.Info(
        title="asdasdsad",
        default_version='v1',
    ),
    public=False,
    permission_classes=(permissions.AllowAny,)
)
swagger_info = openapi.Info(
    title="Snippets API",
    default_version='v1',
    description="""This is a demo project for the [drf-yasg](https://github.com/axnsan12/drf-yasg) Django Rest Framework library.

The `swagger-ui` view can be found [here](/cached/swagger).  
The `ReDoc` view can be found [here](/cached/redoc).  
The swagger YAML document can be found [here](/cached/swagger.yaml).  

You can log in using the pre-existing `admin` user with password `passwordadmin`.""",  # noqa
    terms_of_service="https://www.google.com/policies/terms/",
    contact=openapi.Contact(email="[email protected]"),
    license=openapi.License(name="BSD License"),
)

SchemaView = get_schema_view(
    validators=['ssv', 'flex'],
    public=True,
    permission_classes=(permissions.AllowAny,),
)

and in the end i use paths like below :


urlpatterns = [
path('', include(router.urls)),
# re_path("^swagger(?P<format>.json|.yaml)$", SchemaView.without_ui(cache_timeout=0), name='schema-json'),
path("swagger/", SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path("redoc/", SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('admin/', admin.site.urls),
] 

now when i run python manage.py runserver and when i navigate to localhost:8000/swagger i get this error :


  AttributeError at /swagger/
'NoneType' object has no attribute 'title'

Request Method: GET
Request URL: http://127.0.0.1:8000/swagger/
Django Version: 2.2.2
Python Executable: /usr/bin/python
Python Version: 3.6.8
Python Path: ['/home/farshad/Desktop/django', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/farshad/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Thu, 20 Jun 2019 08:11:35 +0000
Installed Applications:
['rest_framework',
 'drf_yasg',
 'django.contrib.admin',
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant