Skip to content
Snippets Groups Projects
Commit b6b487ba authored by David Trattnig's avatar David Trattnig
Browse files

Avoid rendering of None values in JSON.

parent 560c784c
No related branches found
No related tags found
No related merge requests found
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
import datetime import datetime
from sqlalchemy import create_engine, Column, DateTime, String, Integer, Boolean from sqlalchemy import create_engine, Column, DateTime, String, Integer, Boolean
from sqlalchemy.event import listen from sqlalchemy.event import listen
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow from flask_marshmallow import Marshmallow
from marshmallow import Schema, fields, post_dump
db = SQLAlchemy() db = SQLAlchemy()
ma = Marshmallow() ma = Marshmallow()
...@@ -163,6 +164,14 @@ class PlayLogSchema(ma.SQLAlchemyAutoSchema): ...@@ -163,6 +164,14 @@ class PlayLogSchema(ma.SQLAlchemyAutoSchema):
model = PlayLog model = PlayLog
sqla_session = db.session sqla_session = db.session
SKIP_VALUES = set([None])
@post_dump
def remove_skip_values(self, data, many=False):
return {
key: value for key, value in data.items()
if value not in self.SKIP_VALUES
}
class TrackSchema(ma.SQLAlchemySchema): class TrackSchema(ma.SQLAlchemySchema):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment