From 432aafef9dc13d461255b3470444d05d0b82d460 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Sun, 11 Jun 2023 13:56:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=BC=94=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/demo/models.py | 3 ++- app/demo/views.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/demo/models.py b/app/demo/models.py index 67e4f98..1be11ac 100644 --- a/app/demo/models.py +++ b/app/demo/models.py @@ -1,7 +1,6 @@ from enum import IntEnum, unique import peewee as pw -from functools import cached_property from app.db.base_model import BaseModel @@ -20,6 +19,8 @@ class DemoTable(BaseModel): status = pw.SmallIntegerField(default=Status.RUNNING.value) sex = pw.BooleanField(default=0) + # 假设修改了数据库字段 + # 数据库对象转字典时需要移除的字段 __exclude__ = ["desc", "sex"] diff --git a/app/demo/views.py b/app/demo/views.py index a5d4fdc..a905d1a 100644 --- a/app/demo/views.py +++ b/app/demo/views.py @@ -1,5 +1,5 @@ from flasgger import swag_from -from flask import request, current_app +from flask import current_app, request from flask.views import MethodView from app.demo.models import DemoTable @@ -54,4 +54,4 @@ class DemoCreate(MethodView): # 返回json格式的数据,数据必须可以json序列化 # to_dict 方法可以将对象转成字典 - return json_response(data=res.to_dict()) \ No newline at end of file + return json_response(data=res.to_dict()) -- Gitee