1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

[1.2.X] Migrated the field_subclsasing doctests. Thanks to Alex Gaynor.

Backport of r13780 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13797 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2010-09-12 20:10:43 +00:00
parent f7f2c7251a
commit 106600edb6
3 changed files with 63 additions and 63 deletions

View File

@@ -53,18 +53,18 @@ class SmallField(models.Field):
class JSONField(models.TextField):
__metaclass__ = models.SubfieldBase
description = ("JSONField automatically serializes and desializes values to "
"and from JSON.")
def to_python(self, value):
if not value:
return None
if isinstance(value, basestring):
value = json.loads(value)
return value
def get_db_prep_save(self, value):
if value is None:
return None