Skip to content
Browse files

allow it to be json serializable

  • Loading branch information...
1 parent 47d050c commit 029dd1263794ec36c327617cd6c2346da81c8c33 @andymckay committed Oct 26, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 uuidfield/fields.py
View
11 uuidfield/fields.py
@@ -115,11 +115,12 @@ def to_python(self, value):
compatibility, as ``StringUUID`` implements ``__unicode__`` with
``uuid.UUID.hex()``.
"""
- if not value:
- return None
- # attempt to parse a UUID including cases in which value is a UUID
- # instance already to be able to get our StringUUID in.
- return StringUUID(smart_unicode(value))
+ # Just returns the hex value rather than StringUUID so that it is
+ # JSON serializable. TODO: find a better solution and upstream.
+ try:
+ return value.hex
+ except AttributeError:
+ return value
def formfield(self, **kwargs):
defaults = {

0 comments on commit 029dd12

Please sign in to comment.
Something went wrong with that request. Please try again.