FireO icon indicating copy to clipboard operation
FireO copied to clipboard

no support for nesting models inside list or map fields

Open SaadAttieh opened this issue 3 years ago • 2 comments

support for the following types of models (pseudo code):

class User(Address):
    street = TextField()
    city = TextFielder()
    ...

class User(Model):
    name = TextField()
    addresses = ListField(Address())

or

    addresses = MapField(Address())
#key of map would of course be string, value would be address model.

SaadAttieh avatar Apr 27 '21 05:04 SaadAttieh

Check this comment FlexibleNestedModelField by monthero

And see if it solve your problem

AxeemHaider avatar Apr 29 '21 07:04 AxeemHaider

Hi @SaadAttieh ,

I tried this way and it worked for me, see if it is what you want:

class UserAddress(Model):
    street = TextField()
    city = TextField()
    ...

class User(Model):
    name = TextField()
    addresses = MapField(UserAddress())

R4Ajeti avatar Feb 07 '22 14:02 R4Ajeti

I added support in this PR. It allows any number of levels of nested objects/lists

ADR-007 avatar Feb 11 '23 01:02 ADR-007

@ADR-007 @AxeemHaider I believe nesting a model as a value of a map is still not achieveable, do you confirm?

example: Mapfield(TextField, NestedModelField(SomeModel))

aelamran avatar Oct 18 '23 14:10 aelamran

Hi @aelamran , you are right. I didn't implement it for MapField, only for ListField (as far as I remember)

ADR-007 avatar Oct 18 '23 14:10 ADR-007