根據Django文檔,ChoiceField接受an iterable of two tuples, "or a callable that returns such an iterable"作爲該字段的選項。 我我的表格中定義ChoiceFields: class PairRequestForm(forms.Form):
favorite_choices = forms.ChoiceF
下面我有一個簡單的模型不同orderingfilter: class Ingredient(models.Model):
name = models.CharField(max_length=30)
我使用Django的休息框架API端點。 class IngredientListAPIView(ListAPIView):
queryset = Ingredient.obj