Opened 15 years ago
Closed 15 years ago
#11220 closed (wontfix)
__similar in filter
Reported by: | Filip Gruszczyński | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I would like to propose a new filtering method for char fields, that could be used instead of __exact
or __iexact. __similar
would return models, which field is similar to the given string. Example use case looks like this: user wants to search for some term, so we try to find objects, that satisfy his query.
objects = Klass.objects.filter(name__iexact=user_term) if objects.count() > 0: return render_to_response('found.html', {'objects': 'objects'}) else: names = Klass.objects.filter(name__similar=user_term).values('name') return render_to_response('did_you_mean.html', {'names': names})
If he inputs name, that can't be found, we try to find to some suggestions, like Google does. I don't really know, if databases support this kind of operations. Could this be done? If it can be done and someone could point me, where I should start, I could try to create a patch.
Change History (2)
comment:1 by , 15 years ago
Description: | modified (diff) |
---|
comment:2 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is not a feature of most RDBMS as far as I know. I suggest taking a look at Haystack which does have a feature like this.
Fixed formatting, please use preview.