Django管理编辑表单上的内联对象

2024-10-02 00:23:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下型号:

class ProjectBudget(models.Model):

它有一个窗体和内联:

^{pr2}$

在表单上我有一个字段file。我想从这个文件填充内联对象ProjectSpents值:

class ProjectBudgetForm(ModelForm):
    file  = forms.FileField

    def clean_file(self):
        parse file then populate inline model objects ProjectSpents....

问题是我想从clean_文件编辑ProjectSpents的内联值,但是有一个问题,因为在clean_文件之前queryset已经被填满,而新的内联值则没有 shoiwing公司。也许还有别的解决办法?在


Tags: 文件对象clean表单modelmodels窗体class

热门问题