<img src="...">
is supposed to be a link to an image, not an image. If you want to inline the binary data you can try:
import base64
encoded_qr_code = base64.b64encode(qr_code)
and
<img src="data:image/gif;base64,{{=encoded_qr_code}}">
May not work on older browsers.