method field is not called
See original GitHub issueWhy the method field is not called when loading a dict?
from marshmallow import Schema, fields
class UserSchema(Schema):
first_name = fields.Str(load_from='name')
email = fields.Email()
custom = fields.Method('yo')
def yo(self, obj):
return 'custom'
schema = UserSchema()
result = schema.load({'name': 'j', 'email': 'j@j.jom'})
print result.data # prints {'first_name': u'j', 'email': u'j@j.jom'}
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
DRF SerializerMethodField not getting called - Stack Overflow
In the response I'm getting only the bg_colors field. The other field is absent from response, and its get_field method is also not...
Read more >Function field method is not called for tree view - Odoo
Hello, I have a function field in a tree view that is supposed to display a calculated field, but for some reason the...
Read more >How to create custom model fields - Django documentation
All of Django's fields (and when we say fields in this document, we always mean model fields and not form fields) are subclasses...
Read more >Fields - C# Programming Guide | Microsoft Learn
A field in C# is a variable of any type that is declared directly in a class or struct. Fields are members of...
Read more >Class Fields, Constructors, and Methods
method that can tell you the student's name when calling the method.) - Now, let's take a look at a declaration of a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Never mind. It’s only called when
dumping
notloading
. But why?To elaborate: I needed to use the
deserialize
kwarg toMethod()
to get what I wanted, and the field had to be present to get processed.