summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorprathamesh2021-03-24 12:56:33 +0530
committerprathamesh2021-03-24 12:56:33 +0530
commitf38664721ed117f445b27af839fe41898ed90a47 (patch)
tree7201135da9b74729dce26747a0a7cee05a760a23 /yaksh/models.py
parenta43a152bc36717fd85493d91e6fa5d67c3ce4e5d (diff)
downloadonline_test-f38664721ed117f445b27af839fe41898ed90a47.tar.gz
online_test-f38664721ed117f445b27af839fe41898ed90a47.tar.bz2
online_test-f38664721ed117f445b27af839fe41898ed90a47.zip
Modify QR code functionality, courtesy @adityacp
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index d792205..efe772c 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -3360,8 +3360,10 @@ class QRcode(models.Model):
def generate_image(self, content):
img = qrcode.make(content)
- path = os.path.join(settings.MEDIA_ROOT, 'qrcode',
- '{0}.png'.format(self.short_key))
+ qr_dir = os.path.join(settings.MEDIA_ROOT, 'qrcode')
+ if not os.path.exists(qr_dir):
+ os.makedirs(qr_dir)
+ path = os.path.join(qr_dir, f'{self.short_key}.png')
img.save(path)
self.image = os.path.join('qrcode', '{0}.png'.format(self.short_key))
self.activate()