【发布时间】:2012-07-25 07:05:28
【问题描述】:
我有以下型号:
class ProjectBudget(models.Model):
它有一个表格和内联:
class ProjectBudgetAdmin(admin.ModelAdmin):
form = ProjectBudgetForm
inlines= [ProjectSpentsInline]
class ProjectSpentsInline(admin.TabularInline):
model = ProjectSpents
在表单上我有一个字段file。我想从这个文件中填充内联对象ProjectSpents 值:
class ProjectBudgetForm(ModelForm):
file = forms.FileField
def clean_file(self):
parse file then populate inline model objects ProjectSpents....
问题是我想从 clean_file 编辑 ProjectSpents 的内联值,但是有一个问题,因为在 clean_file 之前查询集已经被填充并且新的内联值没有 显示。也许还有其他解决方案?
【问题讨论】:
标签: python django django-models django-forms