Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 Model 字段,其中包含 ManyToMany 字段,我想在其中选择多项选择。将显示默认选择。如何覆盖以显示 Sumo 选择而不是那个。
class SampleForm(forms.ModelForm): many_to_many_field = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple, queryset=ModelName.objects.all()) class Meta: model = ModelName fields = "__all__"
您可以在此处指定所需的小部件。