In my question, there are three related models:
class DicSoftware(index.Indexed, ClusterableModel):
name = models.CharField("软件名称", max_length=255, blank=True)
version = models.CharField("版本号", max_length=255, blank=True)
panels = [MultiFieldPanel([
FieldPanel('name', classname="col10"),
FieldPanel('version', classname="col10"),
], "模拟软件")]
class Simulation(index.Indexed, ClusterableModel):
name = models.CharField("算例名称", max_length=255, blank=True)
software = ParentalManyToManyField('DicSoftware', related_name='模拟软件')
panels = [ MultiFieldPanel([
FieldPanel('name', classname="col10"),
FieldPanel('software', classname="col10"),
], "算例")]
With these two models above, wagtail automatically generate table simulation_software with three fields, id, simulation_id, dicsoftware_id. However, I want to add other two fields in table simulation_software, inputFile and inputFilePath. The model of the final table simulation_software should be:
class SimulationSoftware(index.Indexed, ClusterableModel):
simulation = models.ForeignKey(Simulation, verbose_name="算例", help_text="/admin/home/simulation/", on_delete=models.CASCADE, blank=True, null=True, related_name='+')
software = models.ForeignKey(DicSoftware, verbose_name="模拟软件", help_text="/admin/home/dicsoftware/", on_delete=models.CASCADE, blank=True, null=True, related_name='+')
#把读入的文件内容存入inputJSON
inputFile = models.FileField("初始化参数文件", upload_to="files", default="")
outputFilePath = models.CharField("结果文件存储位置", max_length=255, blank=True)
panels = [MultiFieldPanel([
FieldPanel('simulation', classname="col10"),
FieldPanel('software', classname="col10"),
FieldPanel('inputFile', classname="col10"),
FieldPanel('outputFilePath', classname="col10"),
], "算例输入")]
When users add one simulation, they have to give the information as follows:
- simulation name.
- specify the software(one or more software) used in this simulation.
In one simulation, there can be one or more sofware. If two software are used in this simulation, users should give these information at the same time:
- the first sofware's inputFile and outputFilePath.
- the second sofware's inputFile and outputFilePath.
How to manage the models' structure and the input panels for inputFiles and outputFilePaths of the software(one or more software).
Anyone can give me some sugguestions? Wish for your help. Thank you very much!