﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36202	Add examples with nested arrays/objects to JSONField docs for __contains and __contained_by	Jacob Walls	Clifford Gama	"With data in a JSON field like:
{{{
{""key"": [1, 2]}
}}}

I was initially surprised to find that this returns a match, since I assumed the values would be compared by equality when determining whether the top-level contains:
{{{
.filter(field__contains={""key"": [1]})  # the additional value in the array doesn't matter
}}}
----

The [https://docs.djangoproject.com/en/5.1/topics/db/queries/#contains docs] say:
> The returned objects are those where the given dict of key-value pairs are all contained in the top-level of the field.

From this sentence I assumed values were checked by equality, not containment all the way down. Apparently this is how it is supposed to work, see #31836. Of course strings don't behave this way, `{""key"": ""value""}` does not contain `{""key"": ""val""}`.

This seems tricky enough to warrant a little example?"	Cleanup/optimization	closed	Documentation	5.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
