I'm using this library to create a QR code for every newly created user. However, when the QR code is generated for each user, it's difficult to differentiate between the two when two users are created. In other words, the QR codes look too similar. How can I generate QR codes that are distinct from each other and not familiar to others?
signals.py:
@receiver(post_save, sender=User)
def create_account(sender, instance, created, **kwargs):
if created:
random_number = ''.join(random.choices(string.digits, k=20))
img = qrcode.make('cullize')
# Define the directory where the image should be saved within the 'media' folder
img_dir = os.path.join(settings.MEDIA_ROOT, 'qrcode')
os.makedirs(img_dir, exist_ok=True) # Create the directory if it doesn't exist
# Define the complete path to save the image
img_path = os.path.join(img_dir, 'default.png')
# Save the QR code image
img.save(img_path)
Account.objects.create(
user=instance,
qr_code=os.path.relpath(img_path, settings.MEDIA_ROOT),
account_id=random_number
)
I'm following this tutorial.