sultan
sultan

Reputation: 6058

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)

Sultan

Upvotes: 0

Views: 1981

Answers (1)

DrTyrsa
DrTyrsa

Reputation: 31951

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

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

Upvotes: 1

Related Questions