1 回答
TA贡献1946条经验 获得超3个赞
class CoderListView(ListView):
model = Question
template_name = "coder/coder_list.html"
context_object_name = 'question'
class CoderDetailView(DetailView):
model = Question
template_name = "coder/coder_detail.html"
context_object_name = 'question'
class CoderCreateView(CreateView):
model = Answer
fields = ['result']
context_object_name = 'answer'
template_name = "coder/coder_form.html"
def get_success_url(self):
question = self.object.question
return reverse('coder:detail', kwargs={'pk': question.id})
def form_valid(self, form):
form.instance.question = Question.objects.get(id=self.kwargs['qid'])
return super().form_valid(form)
我想要更改的视图(基于比较器方法的返回值切换布尔字段是 CodeCreateView,因为用户将提交文件,然后我的方法将检查它是否与解决方案相同)。
添加回答
举报