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.
精彩评论