Eliminate errors that occur when using Django REST Swagger with Django 3.0

Overview

Eliminate errors with Django REST Swagger in Django 3.0

environment

Error message

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

How to solve

#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

Eliminate errors that occur when using Django REST Swagger with Django 3.0
When you want to filter with Django REST framework
When using optparse with iPython
[Tips] Dealing with errors that occur when trying to install Python 3 series less than 3.5.3 with pyenv
Errors that often occur in django Part 1 About template.exceptions.TemplateDoesNotExist (Note)
How to resolve CSRF Protection when using AngularJS with Django
DEBUG settings when using Django
Django REST framework with Vue.js
Login with django rest framework
Implementation of CRUD using REST API with Python + Django Rest framework + igGrid
[Django] Use MessagePack with Django REST framework
When using MeCab with virtualenv python
Precautions when using six with Python 2.5
Note that admin.py is not reflected immediately when running Django with WSGIDaemonProcess
Create RESTful APIs with Django Rest Framework
CRUD GET with Nuxt & Django REST Framework ②
CRUD POST with Nuxt & Django REST Framework
DB settings when using Django + SQLAlchemy + Alembic
CRUD GET with Nuxt & Django REST Framework ①
Application development using SQLite with Django (PTVS)