1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Description: Fixed unicode handling for Python 3
Cast with unicode() function, but it is not in Python 3.
So change str() instead of unicode().
Last-Update: 2014-08-14
Author: Kouhei Maeda <mkouhei@palmtb.net>
Index: django-shortuuidfield-0.1.2/shortuuidfield/fields.py
===================================================================
--- django-shortuuidfield-0.1.2.orig/shortuuidfield/fields.py 2014-08-14 10:48:32.224072792 +0900
+++ django-shortuuidfield-0.1.2/shortuuidfield/fields.py 2014-08-14 10:49:03.260218304 +0900
@@ -1,4 +1,5 @@
import shortuuid
+import sys
from django.db.models import CharField
@@ -30,7 +31,10 @@
value = super(ShortUUIDField, self).pre_save(model_instance, add)
if self.auto and not value:
# Assign a new value for this attribute if required.
- value = unicode(shortuuid.uuid())
+ if sys.version_info < (3, 0):
+ value = unicode(shortuuid.uuid())
+ else:
+ value = str(shortuuid.uuid())
setattr(model_instance, self.attname, value)
return value
|