3
我正在嘗試更新ModelForm中ModelMultipleChoiceField的查詢集。動態更新ModelForm中ModelMultipleChoiceField的查詢集
BaseWriteForm是一個的ModelForm,我的課看起來像如下:
class MyWriteForm(BaseWriteForm):
"""The form for an authenticated user, to compose a message."""
recipients = forms.ModelMultipleChoiceField(label=_('To'),
widget=forms.SelectMultiple(attrs={'class': 'chzn-select'}),
queryset = User.objects.all())
def __init__(self, users_list, **kw):
self.fields['recipients'].queryset = User.objects.filter(pk__in=users_list)
super(BaseWriteForm, self).__init__(**kw)
class Meta(BaseWriteForm.Meta):
fields = ('recipients', 'subject', 'body')
在這種情況下,我有: 'MyWriteForm' 對象有沒有屬性 '域'
謝謝!