简体   繁体   English

Django 自定义视图在从 1.1 更新到 2.2 后停止工作

[英]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) .我从 1.1 更新到 Django 2.2,它似乎可以完美地工作,但是一个特定的视图停止工作并返回Internal Server Error (500) I have troubleshooted for hours and found the core issue is in the ScheduleView.我已经排查了几个小时,发现核心问题出在 ScheduleView 中。 If I change the view to a Django premade view, it works.如果我将视图更改为 Django 预制视图,它可以工作。 What do I miss?我想念什么?

ScheduleView class时间表查看 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.这是 Django 2.2 中的语法错误,所以我不得不给出一个“渲染器”参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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