{"action":"closed","issue":{"url":"https://api.github.com/repos/marshmallow-code/marshmallow/issues/166","labels_url":"https://api.github.com/repos/marshmallow-code/marshmallow/issues/166/labels{/name}","comments_url":"https://api.github.com/repos/marshmallow-code/marshmallow/issues/166/comments","events_url":"https://api.github.com/repos/marshmallow-code/marshmallow/issues/166/events","html_url":"https://github.com/marshmallow-code/marshmallow/issues/166","id":61283421,"number":166,"title":"Field 'only' parameter should only apply to serialization","user":{"login":"andrewmillspaugh","id":4351802,"avatar_url":"https://avatars.githubusercontent.com/u/4351802?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewmillspaugh","html_url":"https://github.com/andrewmillspaugh","followers_url":"https://api.github.com/users/andrewmillspaugh/followers","following_url":"https://api.github.com/users/andrewmillspaugh/following{/other_user}","gists_url":"https://api.github.com/users/andrewmillspaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewmillspaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewmillspaugh/subscriptions","organizations_url":"https://api.github.com/users/andrewmillspaugh/orgs","repos_url":"https://api.github.com/users/andrewmillspaugh/repos","events_url":"https://api.github.com/users/andrewmillspaugh/events{/privacy}","received_events_url":"https://api.github.com/users/andrewmillspaugh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-13T22:38:39Z","updated_at":"2015-09-16T23:39:31Z","closed_at":"2015-09-16T23:39:31Z","body":"If I have\r\n\r\n```python\r\nimport marshmallow\r\n\r\nclass FooSchema(marshmallow.Schema):\r\n    id = marshmallow.fields.Integer()\r\n    bar = marshmallow.fields.Nested('BarSchema', only='id')\r\n    # comment here so this is paste-able into REPL\r\n    def make_object(self, data):\r\n        try:\r\n            return Foo(**data)\r\n        except Exception as e:\r\n            print('Bad data: {}'.format(data))\r\n            raise e\r\n\r\nclass BarSchema(marshmallow.Schema):\r\n    id = marshmallow.fields.Integer()\r\n    baz = marshmallow.fields.String()\r\n    # comment here so this is paste-able into REPL\r\n    def make_object(self, data):\r\n        try:\r\n            return Foo(**data)\r\n        except Exception as e:\r\n            print('Bad data: {}'.format(data))\r\n            raise e\r\n\r\nclass Foo(object):\r\n    def __init__(self, id, bar):\r\n        self.id = id\r\n        self.bar = bar\r\n\r\nclass Bar(object):\r\n    def __init__(self, id, baz):\r\n        self.id = id\r\n        self.baz = baz\r\n```\r\n\r\n...and I want to serialize, I get:\r\n\r\n```python\r\n>>> FooSchema().dump(Foo(1, Bar(2, 'qux'))).data\r\n{'bar': 2, 'id': 1}\r\n```\r\n\r\n...which is correct behavior. However, if I want to deserialize, I get:\r\n```python\r\n>>> FooSchema().load({'id': 1, 'bar': {'id': 2, 'baz': 'qux'}})\r\nBad data: {'id': 2}\r\nTypeError: __init__() takes exactly 3 arguments (2 given)\r\n```\r\n\r\nIn order to get this to work, I have to modify the original code and remove the ```only='id'``` parameter, which then changes my serialization behavior to:\r\n```python\r\n>>> FooSchema().dump(Foo(1, Bar(2, 'qux'))).data\r\n{'bar': {'baz': u'qux', 'id': 2}, 'id': 1}\r\n```\r\n\r\nSo, I think that the ```only``` parameter should apply only to serialization. However, I could foresee that being a problem if you don't want users to be able to create sub resources by nested deserialization. You could, then, have Nested fields take an optional ```deserialize_fields``` parameter which overrode the ```only``` parameter in the case of deserialization."}}