使用ManyToMany中的变量作为UpdateView Django 1.10中的字段

时间:2017-02-16 10:28:37

标签: python django

我定义的模型由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吗?

0 个答案:

没有答案