python - Django DISTINCT match pattern with tolerance -


see older question

i wondering if there new features available (preferably native django) find distinct entries in item model tolerance.

a simple example; have these 5 item-names:

  • item1 linen shirt
  • item2 linen shirt
  • itemb linen shirt1
  • item linen skirt
  • itemc linen skirt2

i like:

item_set = item.objects.distinct_special(name, tolerance = 95) 

.. first value field search , second value tolerance percentage.

you can in pure python difflib.

values = """item1 linen shirt item2 linen shirt itemb linen shirt1 item linen skirt itemc linen skirt2"""  data = values.split('\n')  print(difflib.get_close_matches(data[0], data)) 

check documentation get_close_matches additional parameters tolerance.


Comments