Code

Opened 5 years ago

Closed 5 years ago

#11220 closed (wontfix)

__similar in filter

Reported by: gruszczy 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: UI/UX:

Description (last modified by Alex)

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.

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Fixed formatting, please use preview.

comment:2 Changed 5 years ago by Alex

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.