Store os.urandom variable to Sqlite database in Django
问题 I'm trying to store random variable to Sqlite database in Django, but I get this error: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. Here is my code: random_number = os.urandom(16) SomeModel.objects.filter(id=2).update(number=random_number) Models.py: class SomeModel(models.Model): random = models.CharField(max_length=32