2013-09-22 46 views
0

我有一個Django的形式,其爲的ModelForm:的Django的ModelForm FORMSET第一種形式需要

class EducationForm(ModelForm): 
    class Meta: 
     model = Education 

但它實際上是作爲一個formset:

queryset_education = Education.objects.filter(member = edit_member) 
EducationFormSet = modelformset_factory(Education, form = EducationForm) 
form_education = EducationFormSet(queryset = queryset_education) 

我怎樣才能迫使第一形式需要? 我在StackOverflow中看到了一些類似的問題...沒有人幫助我,因爲我沒有從BaseFormSet繼承的類(我應該創建一個嗎?)

謝謝!

Tidhar

回答

1

是的,你應該定義一個formset類與clean方法,並通過在作爲formset參數modelformset_factory

+0

這正是我現在正在嘗試... – TidharPeer

相關問題