marshmallow-mongoengine:Output dump value missing 'None' fieldMongoengine - id field is named NoneMongoEngine — how to custom User model / custom backend for authenticate()Separate mongoengine models in django 1.7How to specify label_attr for a model in a Flask-Admin ModelView using MongoEngine?mongoengine and django rest framework - fields aren't allowed to be optionalUpdate fields only when new value is not NoneWorking with reference fields in marshmallow-mongoengineMongoengine : How to update specific fields of an existing document?flask-marshmallow custom fieldsHow to serialize Decimal Fields in mongoengine marshmallow?
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
What is Cash Advance APR?
Doesn't the system of the Supreme Court oppose justice?
Giving feedback to someone without sounding prejudiced
Delete multiple columns using awk or sed
Does the reader need to like the PoV character?
Make a Bowl of Alphabet Soup
When were female captains banned from Starfleet?
Has the laser at Magurele, Romania reached a tenth of the Sun's power?
Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?
Why is the Sun approximated as a black body at ~ 5800 K?
Pre-mixing cryogenic fuels and using only one fuel tank
Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?
Biological Blimps: Propulsion
Can I say "fingers" when referring to toes?
Mimic lecturing on blackboard, facing audience
Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?
How does electrical safety system work on ISS?
The IT department bottlenecks progress, how should I handle this?
What is going on with gets(stdin) on the site coderbyte?
What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?
Why do ¬, ∀ and ∃ have the same precedence?
A variation to the phrase "hanging over my shoulders"
Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?
marshmallow-mongoengine:Output dump value missing 'None' field
Mongoengine - id field is named NoneMongoEngine — how to custom User model / custom backend for authenticate()Separate mongoengine models in django 1.7How to specify label_attr for a model in a Flask-Admin ModelView using MongoEngine?mongoengine and django rest framework - fields aren't allowed to be optionalUpdate fields only when new value is not NoneWorking with reference fields in marshmallow-mongoengineMongoengine : How to update specific fields of an existing document?flask-marshmallow custom fieldsHow to serialize Decimal Fields in mongoengine marshmallow?
My project uses flask+mongoengine+marshmallow,When I used marshmallow to serialize the model, the returned value lacked field, and the missing field value was None.When using Django to serialize fields, the None value is still output
model
class Author(db.Document):
name = db.StringField()
gender = db.IntField()
books = db.ListField(db.ReferenceField('Book'))
def __repr__(self):
return '<Author(name=self.name!r)>'.format(self=self)
class Book(db.Document):
title = db.StringField()
serializers
class AuthorSchema(ModelSchema):
class Meta:
model = Author
class BookSchema(ModelSchema):
class Meta:
model = Book
author_schema = AuthorSchema()
When I do this:
author = Author(name="test1")
>>> author.save()
<Author(name='test1')>
>>> author_schema.dump(author)
MarshalResult(data='id': '5c80a029fe985e42fb4e6299', 'name': 'test1', errors=)
>>>
not return the books
field
I hope to return
"name":"test1",
"books": None
what should I do?
mongoengine
add a comment |
My project uses flask+mongoengine+marshmallow,When I used marshmallow to serialize the model, the returned value lacked field, and the missing field value was None.When using Django to serialize fields, the None value is still output
model
class Author(db.Document):
name = db.StringField()
gender = db.IntField()
books = db.ListField(db.ReferenceField('Book'))
def __repr__(self):
return '<Author(name=self.name!r)>'.format(self=self)
class Book(db.Document):
title = db.StringField()
serializers
class AuthorSchema(ModelSchema):
class Meta:
model = Author
class BookSchema(ModelSchema):
class Meta:
model = Book
author_schema = AuthorSchema()
When I do this:
author = Author(name="test1")
>>> author.save()
<Author(name='test1')>
>>> author_schema.dump(author)
MarshalResult(data='id': '5c80a029fe985e42fb4e6299', 'name': 'test1', errors=)
>>>
not return the books
field
I hope to return
"name":"test1",
"books": None
what should I do?
mongoengine
add a comment |
My project uses flask+mongoengine+marshmallow,When I used marshmallow to serialize the model, the returned value lacked field, and the missing field value was None.When using Django to serialize fields, the None value is still output
model
class Author(db.Document):
name = db.StringField()
gender = db.IntField()
books = db.ListField(db.ReferenceField('Book'))
def __repr__(self):
return '<Author(name=self.name!r)>'.format(self=self)
class Book(db.Document):
title = db.StringField()
serializers
class AuthorSchema(ModelSchema):
class Meta:
model = Author
class BookSchema(ModelSchema):
class Meta:
model = Book
author_schema = AuthorSchema()
When I do this:
author = Author(name="test1")
>>> author.save()
<Author(name='test1')>
>>> author_schema.dump(author)
MarshalResult(data='id': '5c80a029fe985e42fb4e6299', 'name': 'test1', errors=)
>>>
not return the books
field
I hope to return
"name":"test1",
"books": None
what should I do?
mongoengine
My project uses flask+mongoengine+marshmallow,When I used marshmallow to serialize the model, the returned value lacked field, and the missing field value was None.When using Django to serialize fields, the None value is still output
model
class Author(db.Document):
name = db.StringField()
gender = db.IntField()
books = db.ListField(db.ReferenceField('Book'))
def __repr__(self):
return '<Author(name=self.name!r)>'.format(self=self)
class Book(db.Document):
title = db.StringField()
serializers
class AuthorSchema(ModelSchema):
class Meta:
model = Author
class BookSchema(ModelSchema):
class Meta:
model = Book
author_schema = AuthorSchema()
When I do this:
author = Author(name="test1")
>>> author.save()
<Author(name='test1')>
>>> author_schema.dump(author)
MarshalResult(data='id': '5c80a029fe985e42fb4e6299', 'name': 'test1', errors=)
>>>
not return the books
field
I hope to return
"name":"test1",
"books": None
what should I do?
mongoengine
mongoengine
asked Mar 7 at 5:03
user9998404user9998404
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
When I looked at the source code of the marshmallow-mongoengine
library, I found the solution model_skip_values=()
in the tests file.
def test_disable_skip_none_field(self):
class Doc(me.Document):
field_empty = me.StringField()
list_empty = me.ListField(me.StringField())
class DocSchema(ModelSchema):
class Meta:
model = Doc
model_skip_values = ()
doc = Doc()
data, errors = DocSchema().dump(doc)
assert not errors
assert data == 'field_empty': None, 'list_empty': []
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036423%2fmarshmallow-mongoengineoutput-dump-value-missing-none-field%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When I looked at the source code of the marshmallow-mongoengine
library, I found the solution model_skip_values=()
in the tests file.
def test_disable_skip_none_field(self):
class Doc(me.Document):
field_empty = me.StringField()
list_empty = me.ListField(me.StringField())
class DocSchema(ModelSchema):
class Meta:
model = Doc
model_skip_values = ()
doc = Doc()
data, errors = DocSchema().dump(doc)
assert not errors
assert data == 'field_empty': None, 'list_empty': []
add a comment |
When I looked at the source code of the marshmallow-mongoengine
library, I found the solution model_skip_values=()
in the tests file.
def test_disable_skip_none_field(self):
class Doc(me.Document):
field_empty = me.StringField()
list_empty = me.ListField(me.StringField())
class DocSchema(ModelSchema):
class Meta:
model = Doc
model_skip_values = ()
doc = Doc()
data, errors = DocSchema().dump(doc)
assert not errors
assert data == 'field_empty': None, 'list_empty': []
add a comment |
When I looked at the source code of the marshmallow-mongoengine
library, I found the solution model_skip_values=()
in the tests file.
def test_disable_skip_none_field(self):
class Doc(me.Document):
field_empty = me.StringField()
list_empty = me.ListField(me.StringField())
class DocSchema(ModelSchema):
class Meta:
model = Doc
model_skip_values = ()
doc = Doc()
data, errors = DocSchema().dump(doc)
assert not errors
assert data == 'field_empty': None, 'list_empty': []
When I looked at the source code of the marshmallow-mongoengine
library, I found the solution model_skip_values=()
in the tests file.
def test_disable_skip_none_field(self):
class Doc(me.Document):
field_empty = me.StringField()
list_empty = me.ListField(me.StringField())
class DocSchema(ModelSchema):
class Meta:
model = Doc
model_skip_values = ()
doc = Doc()
data, errors = DocSchema().dump(doc)
assert not errors
assert data == 'field_empty': None, 'list_empty': []
answered Mar 8 at 1:31
user9998404user9998404
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036423%2fmarshmallow-mongoengineoutput-dump-value-missing-none-field%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown