Questions tagged [flask-marshmallow]
106 questions
0
votes
1 answer
How to send multiple Validation Errors to React using Flask and Marshmallow in Backend and Axios for React-Native in Frontend
I am using Marshmallow to validate incoming fields for a simple put request.
Now I am testing the error handling in the frontend to make sure I send the right error messages for the frontend.
I am usually sending data of type
{
password: string,
…

Eve Edomenko
- 421
- 1
- 3
- 13
0
votes
2 answers
How to access different parameter from field.Method in Python
I would like to change my postal code to '' if its None but cannot access the country_code parameter properly to do it. What am I doing wrong?
class AddressSchema(Schema):
def _postal_check(self, postal):
allowed_countries =…

Dionysus
- 27
- 1
- 4
0
votes
1 answer
Marshmallow: why can't I access the fields attributes?
I have a pretty regular schema class like:
class TestSchema(db_schema.SQLAlchemyAutoSchema):
xxx = fields.Str()
name = fields.Str(validate=validate.Length(min=1), required=True, error_messages={"required": "The name is required."})
class…

mimic
- 4,897
- 7
- 54
- 93
0
votes
1 answer
Scalarize a nested field using marshmallow
I have two Database Models like this
class Setting(db.Model):
id = db.Column(db.Integer, id=True)
container_id = ST_db.Column(ST_db.Integer, db.ForeignKey('settings_container.id'))
setting_name = ST_db.Column(ST_db.String(50))
…

SAK
- 169
- 2
- 11
0
votes
1 answer
Changing the information before serialization
I have a database model like:-
class Script(db.Model):
path = db.Column(db.String(50))
and a serializer like:-
class ScriptSchema(ma.Schema):
class Meta:
fields = (
'path'
)
My question is that when I dump the data after…

SAK
- 169
- 2
- 11
0
votes
1 answer
How Does Flask Marshmallow Schema Introspection of Database Models Work?
I am trying to understand how the the introspection of Marshmallow Schemas works. Here's a simple code example:
import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
from pprint import…

D. de Vries
- 417
- 3
- 12
0
votes
1 answer
How do I deserialize a marshmallow_jsonapi.flask schema field into a SQLAlchemySchema PostgreSQL JSONB field?
I have a Flask model with a field called metadata of the JSONB type in PostgreSQL.
class Foo(db.Model):
id = db.Column(db.String(128), primary_key=True)
metadata = db.Column(JSONB)
I'm serializing that as a marshmallow_jsonapi.flask Schema…

MW Frost
- 980
- 1
- 11
- 23
0
votes
1 answer
How to parse enums by value from query parameters using webargs?
I have the next enum:
class EStatus(enum.IntEnum):
NEW = 0
MODIFIED = 1
And schema:
ARGS = {
'status': EnumField(EStatus, by_value=True, required=False)
}
After in Flask I declared GET-method with webargs:
@use_args(ARGS,…

Denis Sologub
- 7,277
- 11
- 56
- 123
0
votes
1 answer
Serializing one to many relationships nested json with flask marshmallow
I have tried to read existing questions about serializing with flask-Marshmallow, but I can't seem to get what I what, I would like to know what am missing :
I want get such a response :
{
"data": [ {"name": "Netherlands tour",
"description":…

Idris Stack
- 546
- 1
- 14
- 36
0
votes
1 answer
Parse Enum Output with Flask Marshmallow Schema
I have a question about flask marshmallow schema. So, I create models like an example below.
class ID(db.Model):
__abstract__ = True
id = db.Column(db.Integer, autoincrement=True, primary_key=True)
class Timestamp(db.Model):
…
0
votes
1 answer
How to add a custom field in Flask-Marshmallow which is not a part of my SQLAlchemy Model
Suppose I have my Model class as below.
class BankAccount(db.Model):
a = db.Column(db.Integer, primary_key=True)
b = db.Column(db.String(80))
And my Schema looks like the below.
class CreateAccountSchema(ma.SQLAlchemyAutoSchema):
class…

Vishal Verma
- 43
- 1
- 6
0
votes
1 answer
How can I serialize a nested object with marshmallow?
I am new to using flask/marshmallow and I have an object that looks like this:
{'field_0': {'field_1': {'field_2': {'field_3': '...', 'value': 'this is the value I want'}}}}
Is it possible to define a schema for this using marshmallow without…

MJR
- 35
- 9
0
votes
1 answer
"Unknown field." in a flask app, when the field exists
I spent all afternoon trying to figure this out. I've checked the flask documentation, mostly flask-marshmallow documentation most notably the sqlalchemy integration part and some other stackoverflow questions.
Is this something to do with…

RedBeard
- 145
- 2
- 15
0
votes
1 answer
AttributeError: 'DummySession' object has no attribute 'query' when loading M2M schema with Click/Flask
I'm using the application factory pattern and I've got a Article object that relates to a Category in a M2M relationship. So far all the routes in the API work as expected. I can create articles with categories via POST MethodViews.
However, I'm…

chasetheskyforever
- 136
- 11
0
votes
0 answers
Flask SQLAlchemy Marshmallow One to Many relation
So I am having a hard time resolving my issue with said technology in the title.
I have several players joining a game. So one game has many players. I am using python flask, sqlalchemy with sqlite backend and marshmallow for marshalling.
These are…

Patrick Hener
- 135
- 5
- 16