django “dict”对象没有属性“headers”:它来自clickjacking.py

dzhpxtsq  于 2023-06-25  发布在  Go
关注(0)|答案(1)|浏览(187)

我有一个为客户生成PDF支票的方法。代码如下

@csrf_exempt
def generate_pdf(request):
    body = ujson.loads(request.body)
    monitoring = Monitoring.objects.filter(tr_id=body['tr_id']).first()
    if not monitoring:
        return {
            "message": MESSAGE['NotDataTrID']
        }

    data = {
        'headers': ["Abdulloh",],
        'user': monitoring.user,
        'tr_id': monitoring.tr_id,
        't_id': monitoring.t_id,
        'type': monitoring.type,
        'pay_type': monitoring.pay_type,
        'sender_token': monitoring.sender_token,
    }
    pdf = render_to_pdf('pdf_template.html', data)
    return HttpResponse(pdf, content_type='application/pdf')

它最终应该生成一个cheqeu。但是我收到一个来自python env的错误,它来自clickjacking.py。任何人都可以帮助。我使用python3.9和centos7作为操作系统

dz6r00yl

dz6r00yl1#

你该换衣服了

if not monitoring:
        return {
            "message": MESSAGE['NotDataTrID']
        }

进入

if not monitoring:
        return HttpResponse({
            "message": MESSAGE['NotDataTrID']
        })
    ```

You are getting this because you should return a proper response for django middleware

相关问题