Eliminate errors with Django REST Swagger in Django 3.0
When accessing http: // localhost: 8000 / swagger /, the following error occurs
django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
rest_framework
static
tz
#Edit swagger html file
$ sudo vim /usr/local/lib/python3.6/site-packages/rest_framework_swagger/templates/rest_framework_swagger/index.html
If you don't know the swagger file path, grep it
$ sudo grep -rl "staticfiles" /usr/local/lib
Before:
{% load staticfiles %}
After: Edit the second line to the following content
{% load static %}
Access http: // localhost: 8000 / swagger / again to connect. Caused by the removal of'staticfiles' in Django3.0.
Official documentation https://docs.djangoproject.com/en/dev/releases/3.0/#features-removed-in-3-0
Recommended Posts