Django Представление на основе классов с httpresponseredirect

Я пытаюсь добавить httpresponseredirect к моему CreateView, основанному на классе, вместо reverse-lazy, но получаю ошибки. Вот мое представление:

class ApplicantCreate(CreateView):
    model = Applicant
    success_message = 'Your application was submitted successfully.'
    form_class = forms.ApplicantForm
    template_name = 'careers/add_applicant.html'
    success_url = reverse_lazy('careers:thanks')

    def form_valid(self, form):
        context = self.get_context_data()
        employer = context['employer']
        education = context['education']
        with transaction.atomic():
            form.instance.created_by = self.request.user
            self.object = form.save()
            if employer.is_valid():
                employer.instance = self.object
                employer.save()
            if education.is_valid():
                education.instance = self.object
                education.save()
        return super(ApplicantCreate, self).form_valid(form)

    def get_success_url(self):
        return reverse_lazy('careers:thanks')

Спасибо за любую помощь.

Вернуться на верх