我定义的模型由printf "%02x\n", $_ for @sorted_numbers;
组成,它与RestaurantFeature
定义了多对多关系。我的models.py的代码:
RestaurantServing
我现在正在尝试实施class RestaurantServing(models.Model):
name = models.TextField(default="")
class RestaurantFeature(models.Model):
location = models.OneToOneField(
Location,
on_delete = models.CASCADE,
primary_key = True,
)
serving = models.ManyToManyField(RestaurantServing)
页面,其中restaurantfeatures_edit
可以删除/添加/选择等。我写过的基于views.py类的方法:
serving
此代码返回错误class RestaurantFeatureEdit(UpdateView):
template_name = 'Restaurants/restaurantfeature_edit.html'
model = RestaurantFeature
fields = ['name', ]
success_url = '/restaurant'
template_name_suffix = '_update_form'
...我已尝试Unknown field(s) (name) specified for RestaurantFeature
并将多个模型添加为fields = ['serving.name',]
。有人可以帮我在UpdateView中获取model = RestaurantFeature, RestaurantServing
吗?