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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user