如何调试不仅仅在生产中工作的ajax django视图功能

时间:2017-05-15 17:18:52

标签: python ajax django postgresql django-rest-framework

如何调试如此大的代码安静,这些代码在本地工作并且在生产中不起作用,考虑到这是djangorestfranewokr装饰器所涵盖的ajax函数 - 调试不起作用,django没有记录任何错误,我遇到的唯一信息只有500.或者Django必须记录错误,有什么不对吗?

@api_view(['POST', ])
def load_dialog(request):
    if request.method == 'POST':
        party_id = request.data['party_id']
        ticket_id = request.data['ticket_id']
        party = UserProfile.objects.get(pk=party_id)
        ticket = Ticket.objects.get(pk=ticket_id)
        try:
            dialog = Dialog.objects.get(Q(sales=party) | Q(sales=request.user.userprofile))
        except Dialog.DoesNotExist:
            dialog = None
        if dialog:
            textbool = None
            if dialog.sales == request.user.userprofile:
                textbool = "show"
            messages = Message.objects.filter(dialog=dialog)

            s_messages = serializers.serialize('json', messages)
            s_textbool = json.dumps(textbool)
            s_dialog_id = json.dumps(dialog.id)
            data = {
               'messages': s_messages,
               'sales': s_textbool,
               'dialog_id':s_dialog_id,
            }
        else:
            owner = ticket.ownership
            new_dialog = Dialog.objects.create(buyer=request.user.userprofile,sales=owner,ticket=ticket)
            textbool = None
            if new_dialog.sales == request.user.userprofile:
                textbool = "show"
            messages = Message.objects.filter(dialog=new_dialog)
            s_messages = serializers.serialize('json', messages)
            s_textbool = json.dumps(textbool)
            s_dialog_id = json.dumps(new_dialog.id)
            data = {
               'messages': s_messages,
               'sales': s_textbool,
               'dialog_id':s_dialog_id,
            }
    else:
        error = "Fuck"
        return error
    return Response(data)

1 个答案:

答案 0 :(得分:0)

在制作中,您可以使用ADMINS设置通过电子邮件启用Error Reporting