ManagersΒΆ
-
class
towel.managers.
SearchManager
Stupid searching manager
Does not use fulltext searching abilities of databases. Constructs a query searching specified fields for a freely definable search string. The individual terms may be grouped by using apostrophes, and can be prefixed with + or - signs to specify different searching modes:
+django "shop software" -satchmo
Usage example:
class MyModelManager(SearchManager): search_fields = ('field1', 'name', 'related__field') class MyModel(models.Model): # ... objects = MyModelManager() MyModel.objects.search('yeah -no')
-
search
(query) This implementation stupidly forwards to _search, which does the gruntwork.
Put your customizations in here.
-
-
towel.managers.
normalize_query
(query_string, findterms=<built-in method findall of _sre.SRE_Pattern object>, normspace=<built-in method sub of _sre.SRE_Pattern object>) Splits the query string in invidual keywords, getting rid of unecessary spaces and grouping quoted words together.
Example:
>>> normalize_query(' some random words "with quotes " and spaces') ['some', 'random', 'words', 'with quotes', 'and', 'spaces']