What I want is to generate a string(key) of size 5 for my users on my website. More like a BBM PIN.
The key will contain numbers and uppercase English letters:
My favourite is
import uuid uuid.uuid4().hex[:6].upper()
If you using django you can set the unique constrain on this field in order to make sure it is unique. https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.unique