Closed wecoon closed 3 years ago
Hi! Below is a working Python program for saving PNG of QR Code
import qrcode
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data('Some data')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save("geeks.png")
Hi all, I tried all options, but couldn't make it work. Now I'm trying to save QR code as .png as documented, but still no luck. Here is my code, maybe someone could help me get back on the track:
models.py
views.py
I think I could be just blind today, but I get AttributeError: 'str' object has no attribute 'write' error in this case. Documentation does not show img.save('') line, but without it, I get AttributeError: 'PymagingImage' object has no attribute '_committed' which makes sense.
What I could be doing wrong? Thanks, everyone