Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Ability to access parent model #64

Closed
rossmacarthur opened this issue Jan 22, 2019 · 1 comment
Closed

Ability to access parent model #64

rossmacarthur opened this issue Jan 22, 2019 · 1 comment
Labels
feature New feature or request

Comments

@rossmacarthur
Copy link
Owner

It would be nice on a Model instance to be able to access the parent model instance. For example

from serde import Model, fields

class SubExample(Model):
    a = fields.Int()
    
    @property
    def parent_id(self):
        return self._parent.id

class Example(Model):
    id = fields.Int()
    b = fields.Nested(SubExample)


e = Example(id=10, b=SubExample(a=5))
assert e.b.parent_id == 10
@rossmacarthur rossmacarthur added the feature New feature or request label Jan 22, 2019
@rossmacarthur
Copy link
Owner Author

Resolved in #83

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant