FilteredSelectMultipleウィジェットを使用するように多対多のスクリプトフィールドを変更しようとしています。「有効な選択肢を選択してください。12は利用可能な選択肢の1つではありません」という検証まで機能します。12は、そのResponseActionの正しいデータベースIDです。
形:
class ResponseConfigurationForm(ModelForm):
scripts=forms.ModelMultipleChoiceField(queryset=ResponseAction.objects.all(),widget=FilteredSelectMultiple("ResponseAction",False,attrs={'rows':'5'}))
class Meta:
model = ResponseConfiguration
スクリプトモデル:
scripts = models.ManyToManyField('ResponseAction')
問題が見つかりません。