python-qrcode と reportlab を使っていますが、画像として保存せずに qrcode を生成して表示したいです。
def member_card(request):
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="carte-membre.pdf"'
p = canvas.Canvas(response)
customer = request.user.customer
p.drawImage('./static/skin/img/carte-membre/carte-membre.jpg', 0, 530)
p.drawString(15, 720, customer.first_name + " " + customer.last_name)
p.drawString(15, 700, "Identifiant: " + customer.zipcode[:2] + " " + unicode(customer.id))
qr = qrcode.make(customer.first_name + "+" + customer.last_name + "+" + customer.zipcode[:2] + "+" + unicode(customer.id))
p.drawImage(qr , 170, 690, 70, 60)
p.showPage()
p.save()
return response
このエラーがあります:
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\django\core\handlers\base.py", line 115, i
n get_response
response = callback(request, *callback_args, **callback_kwargs)
File "c:\Users\Jeremy\Desktop\Izicap\django\izicap\customer\views.py", line 45
, in member_card
p.drawImage(qr , 170, 690, 70, 60)
File "c:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py", line 926, in
drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
File "c:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2123, i
n __init__
ext = string.lower(os.path.splitext(source)[1])
File "c:\Python27\lib\ntpath.py", line 190, in splitext
return genericpath._splitext(p, sep, altsep, extsep)
File "c:\Python27\lib\genericpath.py", line 91, in _splitext
sepIndex = p.rfind(sep)
AttributeError: 'bool' object has no attribute 'rfind'
ありがとうございました