奇迹般有效:
MyCreateView(CreateView):
template_name = "my_template_name"
form_class = MyModelForm
success_url = "/success/"
但以下没有:
MyUpdateView(UpdateView):
template_name = "my_template_name"
form_class = MyModelForm
success_url = "/success/"
我收到此错误:
MyUpdateView is missing a queryset. Define MyUpdateView.model, MyUpdateView.queryset, or override MyUpdateView.get_queryset().
为什么UpdateView
需要model
,queryset
或get_queryset
定义为不会导致错误而CreateView
不会?它不应该能够从ModelForm中使用的模型自动派生它吗?