K
K
Kamral Magaramov2020-06-04 17:49:08
RESTful API
Kamral Magaramov, 2020-06-04 17:49:08

It is necessary for swagger to work, does it give an error?

While processing the request, an error occurs:
TemplateSyntaxError at /swagger-docs/
'staticfiles' is not a registered tag library. Must be one of:
account
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
rest_framework
socialaccount
static
tz
#blog_project.urls
from django.contrib import admin
from django.urls import include, path
from rest_framework.documentation import include_docs_urls
from rest_framework.schemas import get_schema_view
from rest_framework_swagger. views import get_swagger_view # new

API_TITLE = 'Blog API'
API_DESCRIPTION = 'A Web API for creating and editing blog posts.'
schema_view = get_swagger_view(title=API_TITLE) # new

urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include('posts.urls')),
path('api -auth/', include('rest_framework.urls')),
path('docs/', include_docs_urls(title=API_TITLE,
description=API_DESCRIPTION)),# path('schema/', schema_view), # new
path(' swagger-docs/', schema_view), # new
]
#settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'django.contrib.sites',
# 3rd-party apps
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger', # new
'allauth',
'allauth.account',
'allauth. socialaccount',
'rest_auth',
'rest_auth.registration',
# Local
'posts.apps.PostsConfig',
]

REST_FRAMEWORK={
'DEFAULT_PERMISSION_CLASSES':[
'rest_framework.permissions.IsAuthenticated',
],

'DEFAULT_AUTHENTICATION_CLASSES':[
'rest_framework. authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexGott, 2020-07-23
@AlexGott

I replaced {% load staticfiles %} with {% load static %} in the library code
https://github.com/unioslo/mreg/issues/395#issueco...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question