开发者

Django: CreateView fail_url

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)
开发者_如何学C

Sultan


def form_invalid(self, form):    
    return HttpResponseRedirect(self.get_success_url())

But I don't know what's the use of this form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜