Flask_restful add field problem

there is a field in the QaAnswer table in this table. When json returns, I want to add a field to QaAnswer. I don"t know how to add it

.
class QaAnswer(db.Model):
    __tablename__ = "qa_answer"

    id = db.Column(db.Integer, primary_key=True)
    a_questionid = db.Column(db.Integer, nullable=False)
    a_answerid = db.Column(db.Integer)
    a_respondcontent = db.Column(db.String(255), nullable=False)
    a_createtime = db.Column(db.DateTime, nullable=False)
    a_likecount = db.Column(db.Integer)
    a_isshow = db.Column(db.Integer)
    a_userid = db.Column(db.Integer, nullable=False)

I want to return the json of the following style

                "anwserid": 3,
                "respondcontent": "11111",
                "content": "",
                "createtime": "2018-07-20 12:03:07",
                "likecount": "0",
                "userid": 9449

add a field, do not know how to operate

Mar.29,2021

if you use flask-sqlalchemy to manipulate the database, it is difficult to implement your method, but it also uses methods.

you can take a look at my article

Previous: C-sharp Security prompts that ProtectedData does not exist in the context.

Next: How java merges the results of multiple queried list collections into one list collection.

Menu