def filter(self, all_records=False, **filters):
clone = copy.deepcopy(self)<EOL>clone.adapter.add_query(filters.items())<EOL>clone_length = clone.count()<EOL>if clone_length > self._cfg['<STR_LIT>'] and not all_records:<EOL><INDENT>raise Exception("""<STR_LIT>""" % (clone_length, self._cfg['<STR_LIT>'], filters, self._cfg['<STR_LIT>']))<EOL><DEDENT>return clone<EOL>
Applies given query filters. If wanted result is more than specified size,
exception is raised about using all() method instead of filter.

Args:
    all_records (bool):
    **filters: Query filters as keyword arguments.

Returns:
    Self. Queryset object.

Examples:
    >>> Person.objects.filter(name='John') # same as .filter(name__exact='John')
    >>> Person.objects.filter(age__gte=16, name__startswith='jo')
    >>> # Assume u1 and u2 as related model instances.
    >>> Person.objects.filter(work_unit__in=[u1, u2], name__startswith='jo')