我有一个问题,我找不到一个简单的解决方案,使用Flask-Admin和MongoEngine.我有一个名为的Document类ExerciseResourceContent.它有一个"问题"属性,它是一个ListField一个的EmbeddedDocument叫ExerciseQuestion:
class ExerciseResourceContent(ResourceContent):
"""An exercise with a list of questions."""
## Embedded list of questions
questions = db.ListField(db.EmbeddedDocumentField(ExerciseQuestion))
Run Code Online (Sandbox Code Playgroud)
该ExerciseQuestion文件实际上是DynamicEmbeddedDocument:
class ExerciseQuestion(db.DynamicEmbeddedDocument):
"""
Generic collection, every question type will inherit from this.
Subclasses should override method "without_correct_answer" in order to define the version sent to clients.
Subclasses of questions depending on presentation parameters should also override method "with_computed_correct_answer".
"""
_id = db.ObjectIdField(default=ObjectId)
## Question text
question_text = db.StringField(required=True)
## …Run Code Online (Sandbox Code Playgroud)