I'm having a document and its sub-document, which works fine without changing anything which exists. When I add new field to the sub-document, while saving I got "you can only reference documents once they have been saved to the database"
class SkillDetail(EmbeddedDocument):
SkillName = StringField()
EnrollDate = DateField()
#newfield = ListField()
class Skills(Document):
id = IntField()
Name = StringField()
SkillsDetails = EmbeddedDocumentField(SkillDetail)
def update_method(self, skillNamevalue, enrolldate, newFieldValues):
self.SkillsDetails.append(
SkillDetail(SkillName=skillNamevalue, EnrollDate=enrolldate, newfield=newFieldValues))
self.save()
which actually works fine without the newfield in embedded document. But, when I add the newfield (highlighted field in the SkillDetail document) and run the program I got the error mentioned above.
NOTE: actually im calling update_method() method in the Skills class to assign values to the embedded document
kindly help me to solve this problem thanks in advance