Use the contains
lookup, which is overridden on JSONField
. For example, the following may work:
ConfigUserTable.objects.filter(user_types__contains="user_type1")
However, this might depend on how you are storing JSON data in the field. If you are storing the data as a dict, querying on that key will certainly work. I.e. data in this format in the field user_types
:
{"types": ["user_type1", "user_type2", "user_type3"]}
could be queried like so:
ConfigUserTable.objects.filter(user_types__types__contains="user_type1")
Reference: https://docs.djangoproject.com/en/dev/topics/db/queries/#std:fieldlookup-jsonfield.contains