Django 1.3到1.6更新BaseModelClass

时间:2014-06-06 06:10:15

标签: django

我有一个现有的应用程序,它是构建django 1.3,现在我正在更新它1.6。

问题是 -

staff_formset = modelformset_factory(Staff, formset=EventUserFilteredFormSet, form=EventStaffForm, extra=0)

staff = staff_formset(request.POST or None, queryset=event.staff_set.filter(status=STAFF_STATUS_CHOICES.UNASSIGNED).order_by('service','team'),prefix="staff", user=request.user, event=event)

现在EventUserFilteredFormSet类 -

class EventUserFilteredFormSet(BaseModelFormSet):
def __init__(self, *args, **kwargs):
    self.event = kwargs.pop('event',None)
    self.user = kwargs.pop('user',None)
    super(EventUserFilteredFormSet,self).__init__(*args,**kwargs)
    self.management_form.fields['event'] = forms.CharField(widget=forms.HiddenInput,initial=self.event.pk)

def _construct_forms(self):
    import pdb; pdb.set_trace()
    self.forms = []

    for i in xrange(self.total_form_count()):
        try:
            self.forms.append(self._construct_form(i,instance=self.queryset[i], event=self.event), user=self.user)
        except:
            self.forms.append(self._construct_form(i, instance=None, event=self.event, user=self.user))
@property
def empty_form(self):
    return self._get_empty_form(event=self.event)

问题是_construct_forms没有从该类调用?任何人都可以帮助我。

0 个答案:

没有答案