美文网首页
Django中常用第三方库

Django中常用第三方库

作者: 有怪兽变身奥特曼 | 来源:发表于2021-12-27 09:24 被阅读0次

    1.开发Restful Api

    pip install djangorestframework
    

    2.富文本属性

    pip install django-tinymce
    

    3.跨域问题

    pip install django-cors-headers
    

    4.jsonwebtoken

    pip install djangorestframework-jwt
    

    5.AES加密,微信公众号解密

    pip install pycryptodome
    

    6.图片插件

    pip install pillow
    

    7.django admin日期筛选

    pip install django-daterange-filter
    

    8.导出导入

    pip install django-import-export
    

    9.更加快捷的日期处理

    pip install python-dateutil
    

    10.项目依赖文件生成

    pip install pipreqs
    pipreqs ./ --encoding utf-8 --force
    

    11.接口文档生成

    pip install -U drf-yasg
    

    settings

    INSTALLED_APPS = [
      ...
      'django.contrib.staticfiles', 
      'drf_yasg',
      ...
     ]
    

    urls.py

    ...
    from rest_framework import permissions
    from drf_yasg.views import get_schema_view
    from drf_yasg import openapi
    
    ...
    
    schema_view = get_schema_view(
      openapi.Info(
        title="Snippets API",
        default_version="v1",
        description="Test description",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="xxx@xxx.com"),
        license=openapi.License(name="BSD License"),
      ),
      public=True,
      permission_classes=[permissions.AllowAny],
    )
    
    urlpatterns = [
      url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
      url(r'^swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
      url(r'^redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
      ...
    ]
    

    相关文章

      网友评论

          本文标题:Django中常用第三方库

          本文链接:https://www.haomeiwen.com/subject/epzeqrtx.html