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
1 answer

How do I deserialize a different structured JSON data in Marshmallow?

I have a Schema as below: from marshmallow import Schema, fields class ContactSchema(Schema): # ... other fields ... phone = fields.Str() # ... other fields ... However, JSON data I deal with is different: { // ... other data ... …
Eray Erdin
  • 2,633
  • 1
  • 32
  • 66
0
votes
1 answer

marshmallow EmbeddedDocument doesn't work

I made a simple board api with flask-restplus and mongoengie. Also use marshmallow for serialize data. Below code is now I worked. [model] class Article(Document): no = SequenceField() subject = StringField(required=True) content =…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

Flask Sqlalchemy and Marshmallow return Array in Quotes like "[Array]“

I need your help When I want to return an array with SQLAlchemy from my flask-backendserver with a MariaDb, it is always in quotes like this -> "[{obj}, {obj}, {obj}]". my query: units = Unit.query.all() print(units) --> [, ,
Simon
  • 317
  • 3
  • 17
0
votes
1 answer

Marshmallow - how to use loaded data in validation

I am creating an API using marshmallow for the data validation. the data is given to the schema in JSON: data = request.get_json() schema = ItemSchema() evaluated = schema.load(data) if evaluated.errors: return {'message':…
0
votes
1 answer

marshmallow schema validation

I have the following Joi schema validation in my node project, which I am planning to convert into python using marshmallow library. Joi Schema: aws_access_key: Joi.string().label('AWS ACCESS KEY').required().token().min(20), aws_secret_key:…
thotam
  • 941
  • 2
  • 16
  • 31
0
votes
1 answer

Marshmallow result customization

I have the sqlalchemy model with jsonb field and marshmallow schema for this model: class Settings(db.Model): id = db.Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()")) settings =…
NobbyNobbs
  • 1,341
  • 1
  • 11
  • 17
0
votes
3 answers

flask-marshmallow custom fields

I use flask-marshmallow and mongoengine. Also flask-restplus for my API server. Here is my api.py class BoardSchema(ma.Schema): class Meta: fields = ('no', 'title', 'body', 'tags', 'created_at', 'views') board_schema =…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

How to use two different schemas based on a condition?

I have a DatabaseConnection schema with these attributes: db_type, db_connection_details. Now, for my flask app, I am supporting two database types: mysql and postgresql and I have two different schemas for both pertaining to the…
harshit-sh
  • 358
  • 1
  • 3
  • 17
0
votes
1 answer

Flask Schema is not using all the data passed to it

Let me backtrack a little - The problem is actually happening in initializing a Mentor using the MentorSchema we have: class Mentor(db.Model): __tablename__ = 'mentors' id = db.Column(db.Integer, primary_key=True) id_project42 =…
Brendan
  • 1
  • 1
0
votes
2 answers

Grouping object properties into new dictionary within Marshmallow schema

I am trying to serialize an object with Marshmallow in such a way that "related" properties are grouped together into a single dictionary that does not exist on the original object. My code: from marshmallow import Schema, fields, pprint import…
wbruntra
  • 1,021
  • 1
  • 10
  • 18
0
votes
1 answer

Displaying data with '_' characters from Flask API with Angular

I'm trying to build components from my flask API. When I hit the route, I can see the data for the objects I want. However, when I intreprolate in hopes to see it from my front end, I only see certain properties(the ones that have no '_' in their…
nrvaller
  • 353
  • 6
  • 18
0
votes
0 answers

flask API querying items, JSON

I am using a flask API as my rest point for my Angular application. Currently I am testing the API. I tested my /users point to make sure I got all the users. //importing db, app, models, schema etc. from flask import jsonify,…
nrvaller
  • 353
  • 6
  • 18
0
votes
1 answer

Flask-SQLAlchemy: relationship querying and nested object data

I am playing at python RESTful-API with Flask-SQLAlchemy I got struct at querying 1-M relationship between 2 Table, like Location(1) may have many Buildings(m) This is what I did (my project structure): project model __init__.py …
prachyab
  • 101
  • 1
  • 12
0
votes
1 answer

Add a description to a field in Marshmallow

How can I add a field comment or description in Marshmallow? I want to show it in something like Apispec.
bustawin
  • 684
  • 7
  • 11
0
votes
1 answer

Flask-SQLAlchemy: '"{0}" is not a valid field for {1}.'.format(key, obj))

I'm trying to create an API with Flask and SQLAlchemy, my function add_user is working perfectly, get_all users too, but i have some issues on my get users (return a specific user ) selected by email (mail is my primary key). class User(db.Model): …
JeanSec
  • 11
  • 1
  • 6