def count(self):
conn = self._get_connection()<EOL>numFilters = len(self.filters)<EOL>numNotFilters = len(self.notFilters)<EOL>if numFilters + numNotFilters == <NUM_LIT:0>:<EOL><INDENT>return conn.scard(self._get_ids_key())<EOL><DEDENT>if numNotFilters == <NUM_LIT:0>:<EOL><INDENT>if numFilters == <NUM_LIT:1>:<EOL><INDENT>(filterFieldName, filterValue) = self.filters[<NUM_LIT:0>]<EOL>return conn.scard(self._get_key_for_index(filterFieldName, filterValue))<EOL><DEDENT>indexKeys = [self._get_key_for_index(filterFieldName, filterValue) for filterFieldName, filterValue in self.filters]<EOL>return len(conn.sinter(indexKeys))<EOL><DEDENT>notIndexKeys = [self._get_key_for_index(filterFieldName, filterValue) for filterFieldName, filterValue in self.notFilters]<EOL>if numFilters == <NUM_LIT:0>:<EOL><INDENT>return len(conn.sdiff(self._get_ids_key(), *notIndexKeys))<EOL><DEDENT>indexKeys = [self._get_key_for_index(filterFieldName, filterValue) for filterFieldName, filterValue in self.filters]<EOL>tempKey = self._getTempKey()<EOL>pipeline = conn.pipeline()<EOL>pipeline.sinterstore(tempKey, *indexKeys)<EOL>pipeline.sdiff(tempKey, *notIndexKeys)<EOL>pipeline.delete(tempKey)<EOL>pks = pipeline.execute()[<NUM_LIT:1>] <EOL>return len(pks)<EOL>
count - gets the number of records matching the filter criteria

Example:
        theCount = Model.objects.filter(field1='value').count()