From 61cd4d90395450cc2a7075d44e221a7f1f752831 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Wed, 20 Apr 2011 10:37:33 -0300 Subject: [PATCH] Properly convert JSONField values to string when doing dumpdata. Closes gh-53 --- social_auth/fields.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/social_auth/fields.py b/social_auth/fields.py index 46a5f25..283afee 100644 --- a/social_auth/fields.py +++ b/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): @@ -40,3 +41,7 @@ class JSONField(models.TextField): 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))) -- 2.39.5