From f5224d8d1866122ad2ecfb3118ffd724c4dd3cf8 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 4 Dec 2020 12:38:55 +0530 Subject: Add Test Case for upload using QR Code --- yaksh/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 3182cc8..407435e 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -30,7 +30,7 @@ import qrcode import hashlib # Django Imports -from django.db import models +from django.db import models, IntegrityError from django.contrib.auth.models import User, Group, Permission from django.core.exceptions import ValidationError from django.contrib.contenttypes.models import ContentType @@ -3216,8 +3216,9 @@ class QRcode(models.Model): for i in range(40): try: self.short_key = key[0:num] + self.save() break - except django.db.IntegrityError: + except IntegrityError: num = num + 1 def generate_image(self, content): -- cgit