32๐
The problem is that staticfiles
template tag was deprecated in Django 2.2 and is finally removed in Django 3.0
The djagno-rest-swagger
package itself is deprecated and is no longer maintained.
Their GitHub repo recommends something like drf-yasg
19๐
The library is deprecated
Quick fix(at your own risk): go to site-packages/rest_framework_swagger/templates/rest_framework_swagger/index.html
The line with {% load staticfiles %} (line 2) should be {% load static %}. You can edit it manually
- How do I get the django HttpRequest from a django rest framework Request?
- PIL โ libjpeg.so.8: cannot open shared object file: No such file or directory
- Django testing: Got an error creating the test database: database "database_name" already exists
6๐
You can also create a staticfiles.py
in the templatetags
folder of your app and then paste this code:
from django import template
from django.templatetags.static import (do_static as _do_static,static as _static,)
register = template.Library()
def static(path):
return _static(path)
@register.tag('static')
def do_static(parser, token):
return _do_static(parser, token)'
into the file.
But make sure that the your app comes before rest_framework_swagger
in the app list of your settings.py
.
- Validating a Django model field based on another field's value?
- Django QuerySet Custom Ordering by ID
- Django static files on heroku
- Difference between self.request and request in Django class-based view
2๐
The staticfiles template is deprecated in Django 2.2 and removed in Django 3.
We need to override the rest_framework_swagger/index.html
.
Go to site-packages/rest_framework_swagger/templates/rest_framework_swagger
Copy the rest_framework_swagger folder and paste it in your own templates folder
Then replace the line 2 with {% load static %}
in index.html
Hope it works !!
- How do I use perform_create to set a field automatically in Django Rest Framework?
- Django admin add custom filter
- Appropriate choice of authentication class for python REST API used by web app
- 'QuerySet' object has no attribute ERROR, trying to get related data on ManyToMany fields
- Django: default language i18n
1๐
I found out that the django-rest-swagger Module is not available in django 3.0 or more since the template static label is removed.
Please use other swagger packages, such as drf-yasg
- Django's get_current_language always returns "en"
- Change default Django REST Framework home page title
- Can we have Django DateTimeField without timezone?
- How do I handle file upload via PUT request in Django?
0๐
To get around this:
- navigate to your installation path of rest_framework_swagger, for me itโs
env\Lib\site-packages\rest_framework_swagger
- goto
templates/rest_framework_swagger
folder and changestaticfile
tostatic
in your index.html
This is because {% load staticfiles %} and {% load admin_static %} were deprecated in Django 2.1, and removed in Django 3.0.
This work around solution is what you can use till we get it updated in rest_framework_swagger app.
- How to upgrade Django on ubuntu?
- Use of unicode in Django
- Pycharm (Python IDE) doesn't auto complete Django modules
0๐
The django-rest-framework is using the Template Tag staticfiles which was used in Django 2. It was been dropped in Django 3.0, while the django-rest-frame repo is not while update. It was deprecated in 2019. I whould suggest using drf-yasg from
https://github.com/axnsan12/drf-yasg
It preforms a similar function, to provide API docs automatically using swapper. Iโve used it and it seems good enough.
- NoReverseMatch on password_Reset_confirm
- Using Django's built in web server in a production environment
0๐
https://github.com/axnsan12/drf-yasg#quickstart
In settings.py:
INSTALLED_APPS = [
...
'django.contrib.staticfiles', # required for serving swagger ui's css/js files
...
]