Skip to main content

django myframework

Project description

通用后台框架 3.7

特性

  • 在settings 配置INSTALL_APPS即可.
  • 无需配置urls,文件,约定大于配置.
  • 功能按apps目录分离.
  • 前后端分离,后端只返回json
  • 快速生成CURD模型
  • 多国语言
    • python manage.py makemessages -i venv -l en
    • python manage.py compilemessages -l en

    不要使用 django-admin ,会把 venv 带进去

  • 支持OpenApi 自动生成文档,客户端
  • python manage.py generate_swagger -f json -o static/api.json
  • 使用 idea OpenAPI Generator 插件生成客户端,On an OpenAPI Definition JSON or YAML file: Code -> OpenAPI -> Generate from document
  • 使用 jinja2 模板引擎

放弃rest ,不适合业务

  • status_code 不够使用
  • 地址/xx/{id} 形式,容易产生缓存,不容易测试,批量删除与修改不方便
  • rest_framework 默认是使用csrf_exempt
  • 只使用 post ,get 方法

设置apps目录

pycharm -> project structure -> 设置apps目录为source

新建表结构

python manage.py migrate 

前端使用库

redoc

  • 使用 swagger_auto_schema 添加注释文档
  • query_serializer 查询参数 get/post 使用
  • request_body 请求主体 post 用
  • responses 返回
  • 生成 json/yaml 文件
    python manage.py generate_swagger -f yaml - >static/yaml.json
  • OpenAPI Generator 自动生成客户端文件 pycharm 插件 code -> OpenApi

需要解决

  • 统一用 swagger_auto_schema 添加api文档注释,并且增加参数校验

    • 侵入度低,使用 annotations 辅助
  • 返回response 统一带 code 参数有,需要统一增加,返回错误代码,也许动态增加,建议不使用动态生成rsp

  • 请求 body ,query, 需要添加filter,page_size 参数

快速上手 开发流程

创建 app

  1. 与 django 命令相同,不过默认使用 framework 下的 app 模板
python3 manage.py create_app flink_platform

创建增删改查

  1. 定义好 models 后, 执行自动创建 view,template 模板
python3  manage.py create_curd {app_name}.{Model}

部署

  1. 静态文件部署
python manage.py collectstatic

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djmyframework-0.0.7.tar.gz (11.7 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page