Django:CreateView失败_url
我有以下代码,我希望 form_invalid
方法返回与 success_url
相同的页面。 我一直在考虑对 CreateView
进行子类化,但我想了解公众的意见。 如何实现上面描述的事情呢?
class ProgramNew(CreateView):
form_class = ProgramForm
template_name = 'programs/program_list.html'
success_url = '/manage/programs'
....
....
....
def form_invalid(self, form):
# How to return to self.success_url?
return super(ProgramNew, self).form_invalid(form)
苏丹
I've the following code and I want form_invalid
method to return the same page as success_url
.
I've been considering sub-classing CreateView
but I want to know public opinion.
How to realize the thing described above?
class ProgramNew(CreateView):
form_class = ProgramForm
template_name = 'programs/program_list.html'
success_url = '/manage/programs'
....
....
....
def form_invalid(self, form):
# How to return to self.success_url?
return super(ProgramNew, self).form_invalid(form)
Sultan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
但不知道这个表格有什么用。
But I don't know what's the use of this form.