Permalink
Browse files

fix output __repr__ with single quote - bugly work in admin

  • Loading branch information...
1 parent 682bf89 commit af2d59260e93a3b5e0e8402bf50ed5a243da4beb Frol committed Apr 29, 2011
Showing with 12 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 quering_jsonfield/fields.py
  3. +7 −0 quering_jsonfield/utils.py
View
1 .gitignore
@@ -0,0 +1 @@
+*.pyc
View
6 quering_jsonfield/fields.py
@@ -1,15 +1,17 @@
from django.db import models
from django.utils import simplejson as json
+from .utils import JSONDict
+
class JSONField(models.TextField):
__metaclass__ = models.SubfieldBase
def to_python(self, value):
if value:
- value = json.loads(value)
+ value = JSONDict(json.loads(value))
else:
- value = {}
+ value = JSONDict()
return value
def get_db_prep_save(self, value):
View
7 quering_jsonfield/utils.py
@@ -0,0 +1,7 @@
+from django.utils import simplejson
+
+
+class JSONDict(dict):
+
+ def __repr__(self):
+ return unicode(simplejson.dumps(self))

0 comments on commit af2d592

Please sign in to comment.