Questions tagged [marshmallow]

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. (For Questions about Android Marshmallow use the tag [android-6.0-marshmallow].)

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. See https://marshmallow.readthedocs.io/en/latest/index.html

589 questions
0
votes
0 answers

How to save many to many after use schema load

I'm trying to add a new user using marshmallow_sqlalchemy and sqlalchemy to my database. This user has a many to many relationship with my profile table but I dont know how to do it for many to many relationship. I would like to know if this is a…
Diogo Silva
  • 195
  • 3
  • 17
0
votes
1 answer

Override field schema based on data - Marshmallow

I'm just getting started with marshmallow so if there's a more elegant way to solve the issue please let me know. Fields will be varied based on the user type (student/staff) { "type": "student", "name": "Student 1", "class": "V Std", …
Sivaraj S
  • 340
  • 3
  • 14
0
votes
1 answer

ma.Nested probably does not work sqlalchemy and marshmallow

I have one to many relationships between tables in a database and I want to get the data using an API. I think that ma.Nested does not work because I don't get all the fields can anyone help me? I get only this : [ { "IsRef": false, …
Dhia Ben Rajeb
  • 13
  • 1
  • 1
  • 5
0
votes
0 answers

using marshmallow in flask manipulating data before inserting data in database

I am trying to validate my data which i am posting through post request and i want to check if the data i proper or not and with that i want to do type casting and manipulate the data. I have tried to manipulate the data but its not working and i…
0
votes
1 answer

How to unite two marshmellow schemes in one

I use marshmallow to validate my output. I have two marshmallow schemes class IdentitiesList(Schema): items = fields.List(fields.String, required=True) class UsersListSchema(Schema): items = fields.Nested(UserDescriptionSchema,…
0
votes
2 answers

How to perform update partially in Flask?

Is there anyway to update with PUT method in flask restul with partially fields? currently my PUT method perform this however if the fields it's not there gonna throw error. item = ItemModel.find_by_id(id) item_json = request.get_json() …
Kevin
  • 21
  • 1
  • 3
0
votes
2 answers

Sqlalchemy-Marshmallow - Nested field not displaying any data

I was having no problem using nested fields in my flask app when using marshmallow-sqlalchemy with Flask-SQLAlchemy. Now that I've switched from Flask-SQLAlchemy to just SQLAlchemy (for a few irrelevant reasons), my nested fields are no longer…
Sean
  • 515
  • 7
  • 17
0
votes
1 answer

SQLAlchemy - when to make extra models and relationships vs. just storing JSON in column?

I'm writing an app framework for a project, where each app is a set of functions. To describe these functions (parameter schemas, return schemas, plugin info, etc.) I'm using an OpenAPI 3.0-like syntax: https://swagger.io/specification/ These app…
0
votes
0 answers

How to include additional, unknown fields when loading data with marshmallow-mongoengine?

I am building a REST API on top of Flask and Connexion using marshmallow-mongoengine and MongoEngine to work with MongoDB. Problem: If my input data includes additional, unknown fields they are always excluded from the resulting object when loading…
mplaine
  • 15
  • 4
0
votes
0 answers

flask-marshmallow define schema to convert simple json to complex orm

I have some entities in sqlalchemy. They are User and messages which they sent UserMessage: class User(db.Model): __tablename__ = 'User' email = Column(String) class UserMessage(db.Model): __tablename__ = 'UserMessages' date =…
melchoir55
  • 6,842
  • 7
  • 60
  • 106
0
votes
1 answer

Testing a decorator that wraps api routes

I am building a rest api and I was making the routes for the api and stumbled upon a problem. I am using flask restplus to build the api and marshmallow to validate the json sent by the client. My design: I use a decorator that is used to wrap every…
Yang K
  • 407
  • 4
  • 13
0
votes
1 answer

Marshmallow serialization - a way to catch exceptions on a per field basis?

Is there a way to catch exceptions (that occur when accessing a property) on a per-field basis with marshmallow [1] ? I want to use marshmallow to serialize documents of a mongo db (mongoengine) database. With nested schemas, referenced objects are…
mfit
  • 807
  • 13
  • 28
0
votes
0 answers

Sqlalchemy - Create a row when i put a model nested with marshmallow

I trying to put a nested model and it's works, but i can see a new row in my database created in the same time. api/program.py: @app.route("/programs/", methods=["PUT"]) def update_program(id): program = Program.query.filter_by(id=id).first() …
0
votes
1 answer

Flask Marshmallow - schema returning an attribute error?

I am trying to return a list of all keywords from a database that looks something like [ 'foo', 'bar', 'baz', ] Model class Keyword(db.Model, SurrogatePK): __tablename__ = 'keywords' keyword = Column(db.Text, nullable=False,…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
0
votes
1 answer

Can't pass DateTime with timezone to marshmallow

I need to pass a DateTime with timezone to a Flask api, using marshmallow/webargs arguments definitions. I have my argument defined as: from webargs import fields 'from': fields.DateTime(required=False, missing=None) I am calling my api passing the…
cheip
  • 41
  • 5