我有以下型号:
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公司。也许还有别的解决办法?在
尝试重写模型管理方法^{} 。您可以迭代formset实例以删除现有的内联,然后访问
form.cleaned_data['file']
并创建新的相关实例。在相关问题 更多 >
编程相关推荐