marshmallow

AttributeError: type object 'User' has no attribute '_query_cls'

别等时光非礼了梦想. 提交于 2021-02-17 06:56:36
问题 User.id was of type postgresql.UUID Message.sender_id was of type postgresql.UUID with foreignkey to User.id . Changed my type to sqlalchemy_util.UUIDType . I had a problem for serializing my foreign key so I set my own JSONEncoder Now everything is working properly except when creating a Message (other classes with the same configuration does not have the problem). test_message.py def test_create_message(client, db, admin_user, admin_headers): # test bad data data = { 'message': 'foobar',

Flask-sqlalchemy-Marshmallow nesting Schema not working

ぃ、小莉子 提交于 2021-01-28 19:13:27
问题 Basically what i want to do is, join 2 tables 'users' & 'company' and get the users with their relevant company details . this is the user model: class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) firstname = db.Column(db.String(10), nullable=False) lastname = db.Column(db.String(25), nullable=False) username = db.Column(db.String(250), nullable=False) email = db.Column(db.String(100), nullable=False) password = db.Column(db.String

How to serialize a Marshmallow field under a different name

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-17 07:22:21
问题 I want a Marshmallow Schema with the following output json - { "_id": "aae216334c3611e78a3e06148752fd79", "_time": 20.79606056213379, "more_data" : {...} } Marshmallow doesn't serialize private members so this is as close as I can get - class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = fields.String() But I do need the underscores in the output json. Is there a way to tell Marshmallow to serialize the fields using different names? 回答1: https://marshmallow

How to serialize a Marshmallow field under a different name

给你一囗甜甜゛ 提交于 2021-01-17 07:21:36
问题 I want a Marshmallow Schema with the following output json - { "_id": "aae216334c3611e78a3e06148752fd79", "_time": 20.79606056213379, "more_data" : {...} } Marshmallow doesn't serialize private members so this is as close as I can get - class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = fields.String() But I do need the underscores in the output json. Is there a way to tell Marshmallow to serialize the fields using different names? 回答1: https://marshmallow

How to serialize a Marshmallow field under a different name

Deadly 提交于 2021-01-17 07:21:01
问题 I want a Marshmallow Schema with the following output json - { "_id": "aae216334c3611e78a3e06148752fd79", "_time": 20.79606056213379, "more_data" : {...} } Marshmallow doesn't serialize private members so this is as close as I can get - class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = fields.String() But I do need the underscores in the output json. Is there a way to tell Marshmallow to serialize the fields using different names? 回答1: https://marshmallow

How to serialize a Marshmallow field under a different name

风格不统一 提交于 2021-01-17 07:20:13
问题 I want a Marshmallow Schema with the following output json - { "_id": "aae216334c3611e78a3e06148752fd79", "_time": 20.79606056213379, "more_data" : {...} } Marshmallow doesn't serialize private members so this is as close as I can get - class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = fields.String() But I do need the underscores in the output json. Is there a way to tell Marshmallow to serialize the fields using different names? 回答1: https://marshmallow

How to serialize a Marshmallow field under a different name

我的未来我决定 提交于 2021-01-17 07:16:11
问题 I want a Marshmallow Schema with the following output json - { "_id": "aae216334c3611e78a3e06148752fd79", "_time": 20.79606056213379, "more_data" : {...} } Marshmallow doesn't serialize private members so this is as close as I can get - class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = fields.String() But I do need the underscores in the output json. Is there a way to tell Marshmallow to serialize the fields using different names? 回答1: https://marshmallow

how to serialise a enum property in sqlalchemy using marshmallow

蹲街弑〆低调 提交于 2020-11-28 04:54:21
问题 this is my model class class Type(enum.Enum): Certified = "certified" Non_Certified = "non-certified" class Status(enum.Enum): Approved = "Approved" Rejected = "Rejected" Published = "Published" Retired = "Retired" Waiting_for_Approval = "Waiting_for_Approval" class DifficultyLevel(enum.Enum): Beginner = "Beginner" Intermediate = "Intermediate" Advanced = "Advanced" All = "All" class ActiveStatus(enum.Enum): Archive = "archive" Restore = "restore" class Course(Base): __tablename__ = 'course'