Questions tagged [flask-marshmallow]
106 questions
0
votes
1 answer
Combine 2 models with 1:1 relation into one scheme without nesting?
I currently have 2 models which are related by a 1:1 relationship which will always be displayed together. The models are linked via a common PK. I have created the two models which map to their tables using flask-sqlalchemy. I will make a…

Scott Glascott
- 537
- 1
- 5
- 15
0
votes
1 answer
Why does Marshmallow return empty for multiple items but returns a single item?
I'm building an API using Flask and marshmallow to format the query results but for some reason Filter.query.all() is returning empty, but when I replace that with Filter.query.first() it returns the first filter. I've also double checked my…

koopmac
- 936
- 10
- 27
0
votes
1 answer
How to produce the following json using flask-sqlachemy?
I am creating a API endpoints using flask-sqlalchemy and marshmallow in python. For example I have two collections/tables one is items and other is stores. Items will have attributes like item_id, item_name, item_price and available stores_list.…

Himavan
- 385
- 3
- 16
0
votes
1 answer
Nested fields with mashmallow_sqlalchemy and flask_marshmallow
I am trying to get a nested serialized output, but all I get is the 'many' side of the many-to-one's table's primary key.
Expected output:
[{'part_numbers':
{'part_number': '23103048', 'description': 'blue product'},
…

LarsaSolidor
- 135
- 2
- 12
0
votes
0 answers
Flask sqlalachemy and marshmallow: Found schema invalid type
I am new to flask and try to wtite a user role association service. I defined the three database models in a following way:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class user(db.Model):
id = db.Column(db.Integer,…

Khan Hafizur Rahman
- 105
- 14
0
votes
1 answer
How to check if a Marshmallow schema's Datetime field is less than today's date?
I have an endpoint that accepts POST method. The POST body contains a DateTime field of format - "%Y-%m-%d %H:%MZ". I need to validate if that datetime is less than current Datetime in UTC. I'm using Marshmallow to validate the request…

Underoos
- 4,708
- 8
- 42
- 85
0
votes
1 answer
Pass parameters to a decorator Class in Python
I'm trying to write a decorator for a Db Model, to makes this Model serializable
def Schema(cls):
class Schema(marshmallow.ModelSchema):
class Meta:
model = cls
cls.Schema = Schema
return cls
@Schema
class…

Caio Filus
- 705
- 3
- 17
0
votes
1 answer
How can I create a Schema in Marshmallow to reverse-nest queried data?
Sorry if this sounds silly, but i'm trying to get all the books for an author. This is what I have:
class Author(db.Model):
__tablename__='author'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
class…

Pstr
- 777
- 1
- 8
- 17
0
votes
1 answer
Flask-Marshmallow issue with Nested
i trying to use flask-marshmallow to bring data to JSON from one-to-many relationships model but i'm stuck how to use Nested to display in the details all th data from db.relationships. Now it only list with numbers. Here how it looks now. Please…

dmitriy_one
- 477
- 1
- 5
- 16
0
votes
1 answer
How to validate REST api params using regex in flask?
I am working on a REST api using flask/connexion. Consider this endpoint:
http://127.0.0.1:5000/api/library/{category_name}/{version}
category_name and version are from string type. How can I validate them with a custom regex?
I am using sqlalchemy…

hd.
- 17,596
- 46
- 115
- 165
0
votes
1 answer
What is replacement of fields.Method in flask-marshmallow?
I am writing a REST API using python-flask.
I want to do some process on fetched fields before serializing them. So I guess the best solution is fields.Method but it seems fields.Method is removed from marshmallow since 3.0 version. What is the…

hd.
- 17,596
- 46
- 115
- 165
0
votes
1 answer
Flask SQLAlchemy with Flask Marshmallow dump and load with different "column names"
I get the following JSON as an input:
{
"832.547.13 Temperatur 1": "1337",
"832.547.23 Temperatur 2": "2323"
}
But I cant use these JSON-Datafields in my db.Model, so I make this:
class DataModel(db.Model):
id =…

meai2312
- 167
- 4
- 12
0
votes
1 answer
TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'str'
I have a table with some columns which one of theme is 'date' type and is defined as below in sqlalchemy model class:
ConfStartDate = db.Column(Date, nullable=False)
python gives me error "TypeError: descriptor 'isoformat' requires a…

hd.
- 17,596
- 46
- 115
- 165
-1
votes
1 answer
'TypeError: Object of type is not JSON serializable' in Flask Marshmallow SqlAlchemy with Pluck?
I have two related object models that I am attempting to return through a marshmallow schema by using pluck. The primary model is a Product with a related field "technology_pillar" joined on a foreign key that should always return. In the schema…

Justin Kelley
- 1
- 2
-1
votes
1 answer
Flask api rest error in filter using string into request
i implemented in my flask api rest app, this code to get the use from id into database:
@blp.route("/v0/user/")
class User(MethodView):
@blp.response(200, UserSchema)
def get(self, id):
user = UserModel.query.get_or_404(id)
…

dev_
- 395
- 1
- 3
- 16