Fix python3 qrcode and some bugs

This commit is contained in:
Chiaki
2017-05-01 15:20:13 +08:00
parent 043f8c8b26
commit d11f8f9bff
3 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import os
from io import StringIO
from io import BytesIO
import qrcode
from django.conf import settings
@@ -140,7 +140,7 @@ class TwoFactorAuthAPI(APIView):
config = WebsiteConfig.objects.first()
image = qrcode.make(OtpAuth(token).to_uri("totp", config.base_url, config.name))
buf = StringIO()
buf = BytesIO()
image.save(buf, "gif")
return HttpResponse(buf.getvalue(), "image/gif")