Refs #12990 -- Added example to JSONField release notes.
This commit is contained in:
parent
d88952142b
commit
5d4b9c1cab
|
@ -70,8 +70,25 @@ JSONField for all supported database backends
|
||||||
Django now includes :class:`.models.JSONField` and
|
Django now includes :class:`.models.JSONField` and
|
||||||
:class:`forms.JSONField <django.forms.JSONField>` that can be used on all
|
:class:`forms.JSONField <django.forms.JSONField>` that can be used on all
|
||||||
supported database backends. Both fields support the use of custom JSON
|
supported database backends. Both fields support the use of custom JSON
|
||||||
encoders and decoders. The model field supports the introspection, lookups, and
|
encoders and decoders. The model field supports the introspection,
|
||||||
transforms that were previously PostgreSQL-only.
|
:ref:`lookups, and transforms <querying-jsonfield>` that were previously
|
||||||
|
PostgreSQL-only::
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class ContactInfo(models.Model):
|
||||||
|
data = models.JSONField()
|
||||||
|
|
||||||
|
ContactInfo.objects.create(data={
|
||||||
|
'name': 'John',
|
||||||
|
'cities': ['London', 'Cambridge'],
|
||||||
|
'pets': {'dogs': ['Rufus', 'Meg']},
|
||||||
|
})
|
||||||
|
ContactInfo.objects.filter(
|
||||||
|
data__name='John',
|
||||||
|
data__pets__has_key='dogs',
|
||||||
|
data__cities__contains='London',
|
||||||
|
).delete()
|
||||||
|
|
||||||
If your project uses ``django.contrib.postgres.fields.JSONField``, plus the
|
If your project uses ``django.contrib.postgres.fields.JSONField``, plus the
|
||||||
related form field and transforms, you should adjust to use the new fields,
|
related form field and transforms, you should adjust to use the new fields,
|
||||||
|
|
Loading…
Reference in New Issue