Question

I want to know whether I can assign a subclass reference to a referencefield to the constructor of which the base class has been passed. For example:

class Base(Document):
   str1=StringField(max_length=50)

class Derived(Base):
   str2=StringField(max_length=50)

class Container(Document):
    r=ReferenceField(Base)


d=Derived(str1="str1",str2="str2")
c=Container()
c.r=d

Is the line c.r=d valid?

Or do I need to use a GenericReferenceField?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top