简体   繁体   中英

Django MongoDB, create models based on other model

I have one model Foo, it will have a field lets call it "parameters_names". I want to save this model then create a new model with those paramaters_names as fields of the new model.

so for example Foo:

parameters: "Name, Surname, ID_number"

NEW MODEL: 
name = CharField()
surname = CharField()
id_number = CharField()

So the new models might always be different.

How about this?

model FooParams:
    foo = ForeignKey(Foo)
    param = CharField()
    value = CharField()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM