gpt4 book ai didi

python - django_rest_swagger - 'staticfiles' 不是注册的标签库。必须是 : 之一

转载 作者:行者123 更新时间:2023-12-04 09:33:58 30 4
gpt4 key购买 nike

Have this error while trying to autogenerate API docs for django rest framework in django 2.2.4, from what I'm seeing in the logs it has something to do with the deprectation of the {% load staticfiles %}


templateSyntaxError at /
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
countries
i18n
l10n
log
phone
rest_framework
static
tz
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 3.0
Exception Type: TemplateSyntaxError
Exception Value:
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
countries
i18n
l10n
log
phone
rest_framework
static
tz

{% load i18n %}
2 {% load staticfiles %}
3 <!DOCTYPE html>
4 <html lang="en">
5 <head>
6 <meta charset="UTF-8">
7 <title>Swagger UI</title>
8 <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
9 <link href="{% static 'rest_framework_swagger/bundles/vendors.bundle.css' %}" rel="stylesheet" type="text/css">
10 <link href="{% static 'rest_framework_swagger/bundles/app.bundle.css' %}" rel="stylesheet" type="text/css">
11 {% block extra_styles %}
12 {# -- Add any additional CSS scripts here -- #}

我的 urls 文件的格式与 django_rest_swagger 文档中的格式相同:
from django.contrib import admin
from django.urls import path, include
from rest_framework_swagger.views import get_swagger_view


schema_view = get_swagger_view(title='My API')

urlpatterns = [
path('admin/', admin.site.urls),
path('api/user/', include('user.urls'),
path('', schema_view)]

最佳答案

问题是staticfiles template 标签在 Django 2.2 中被弃用,最终在 Django 3.0 中被移除
djagno-rest-swagger包本身已弃用,不再维护。

他们的 GitHub repo推荐类似 drf-yasg 的东西

关于python - django_rest_swagger - 'staticfiles' 不是注册的标签库。必须是 : 之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59230539/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com