'Queries model_class with `chunk_field` set to chunks of size `chunk_size`,
and all other parameters from `**kwargs`.
This works around a limitation in sqlite3 on the number of parameters
that can be put into a single query.
Arguments:
chunk_field (str): The name of the field to chunk the query on.
items: The values for of chunk_field to select. This is chunked into ``chunk_size``
chunks, and passed as the value for the ``chunk_field`` keyword argument to
:meth:`~Manager.filter`. This implies that ``chunk_field`` should be an
``__in`` key.
chunk_size (int): The size of chunks to pass. Defaults to 500.'

def chunked_filter(self, chunk_field, items, **kwargs):

    chunk_size = kwargs.pop('chunk_size', 500)
    res = itertools.chain.from_iterable((self.filter(**dict(([(chunk_field, chunk)] + kwargs.items()))) for chunk in chunks(items, chunk_size)))
    return res
