def _createId():
    return hexlify(os.urandom(16))


class Book(models.Model):
    id_book = models.CharField(max_length=32, primary_key=True, default=
        _createId)
Generate unique hashes for django models