简体   繁体   中英

Django custom view stopped working after updating to 2.2 from 1.1

Backstory: I took over a website from two guys who wanted to abandon it due to financial reasons, but their only client didn't want to change their system, so I took on the job to maintain it.

I updated to Django 2.2 from 1.1 and it seemed to work flawlessly, but a specific view stopped working and returns Internal Server Error (500) . I have troubleshooted for hours and found the core issue is in the ScheduleView. If I change the view to a Django premade view, it works. What do I miss?

ScheduleView class

class ScheduleView(TherapistRequiredMixin, SuccessMessageMixin, FormView):
form_class = ScheduleForm
template_name = "schedule.html"
success_message = "Nya bokningstillfällen är skapade"




def get_success_url(self):
    return reverse('schedule')

def form_valid(self, form):
    ret = form.save()
    if ret:
        messages.error(self.request, ret)
        # return super(ScheduleView, self).form_invalid(form)
        return super().form_invalid(form)
    else:
        # return super(ScheduleView, self).form_valid(form)
        return super().form_valid(form)

Problem solved. It was a syntax error in Django 2.2, so I was forced to give a 'renderer' argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM