Skip to content

Commit

Permalink
Properly convert JSONField values to string when doing dumpdata. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Apr 20, 2011
1 parent 0fc1e45 commit 61cd4d9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions social_auth/fields.py
@@ -1,6 +1,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.utils import simplejson
from django.utils.encoding import smart_unicode


class JSONField(models.TextField):
Expand Down Expand Up @@ -40,3 +41,7 @@ def get_prep_value(self, value):
return simplejson.dumps(value)
except Exception, e:
raise ValidationError(str(e))

def value_to_string(self, obj):
"""Return value from object converted to string properly"""
return smart_unicode(self.get_prep_value(self._get_val_from_obj(obj)))

0 comments on commit 61cd4d9

Please sign in to comment.