How to perform filtering with a Django JSONField?

As per the Django JSONField docs, it explains that that the data structure matches python native format, with a slightly different approach when querying. If you know the structure of the JSON, you can also filter on keys as if they were related fields: object.filter(data__animal=”cat”) object.filter(data__name=”tom”) By array access: object.filter(data__0__animal=”cat”) Your contains example is almost … Read more

Django 1.9 ImportError for import_module

django.utils.importlib is a compatibility library for when Python 2.6 was still supported. It has been obsolete since Django 1.7, which dropped support for Python 2.6, and is removed in 1.9 per the deprecation cycle. Use Python’s import_module function instead: from importlib import import_module The reason you can import it from django.utils.module_loading is that importlib.import_module is … Read more