django-uuidfield icon indicating copy to clipboard operation
django-uuidfield copied to clipboard

coercing to Unicode: need string or buffer, StringUUID found

Open sindresorhus opened this issue 12 years ago • 1 comments

Why do I need to wrap the field in unicode() to make it usable?

unicode(self.order_id)

If I don't I get:

coercing to Unicode: need string or buffer, StringUUID found

This makes it impossible to use in eg. the modellist without wrapping it in a method.

sindresorhus avatar Dec 02 '12 21:12 sindresorhus

This was actually a significant issue for me when I performed an upgrade. I ended up doing this:

class CustomUUIDField(UUIDField): def to_python(self, value): val = super(CustomUUIDField, self).to_python(value) return str(val)

And then simply using my custom uuid field everywhere instead.

fomojola avatar Sep 19 '14 16:09 fomojola