1
0
mirror of https://github.com/django/django.git synced 2025-07-19 09:09:13 +00:00

[1.9.x] Refs #25995 -- Documented that JSONField doesn't handle sophisticated serialization.

Backport of c432dd40bde37667bfe6bb59eaff0a14c50cd27b from master
This commit is contained in:
Tim Graham 2016-01-04 11:07:05 -05:00
parent cb96d0c92a
commit 3503b816cf

View File

@ -467,6 +467,12 @@ JSONField
its Python native format: dictionaries, lists, strings, numbers, booleans
and ``None``.
If you want to store other data types, you'll need to serialize them first.
For example, you might cast a ``datetime`` to a string. You might also want
to convert the string back to a ``datetime`` when you retrieve the data
from the database. There are some third-party ``JSONField`` implementations
which do this sort of thing automatically.
If you give the field a :attr:`~django.db.models.Field.default`, ensure
it's a callable such as ``dict`` (for an empty default) or a callable that
returns a dict (such as a function). Incorrectly using ``default={}``