0
我有下面的表格,我想用我準備的自動完成小部件來覆蓋多個文件夾 。覆蓋ManyToManyField
class AutoCompleteForeignKeyWidget(forms.TextInput):
input_type = 'text'
class FooForm(forms.ModelForm):
regions = forms.CharField(widget=AutoCompleteForeignKeyWidget(attrs={
'class': 'regions', 'placeholder': 'Type Region',
'autocomplete': 'off'
}), required=True)
class Meta:
model = Hotel
exclude = ('regions')
但是這是不成熟的。我有一個完整性錯誤DETAIL: Key (region_id)=(0) is not present in table "destinations_region".
有沒有辦法覆蓋manytomanyfield