class TrigramDistance(expression, string, **extra) [source]
New in Django 1.10.
Accepts a field name or expression, and a string or expression. Returns the trigram distance between the two arguments.
Usage example:
>>> from django.contrib.postgres.search import TrigramDistance
>>> Author.objects.create(name='Katy Stevens')
>>> Author.objects.create(name='Stephen Keats')
>>> test = 'Katie Stephens'
>>> Author.objects.annotate(
... distance=TrigramDistance('name', test),
... ).filter(distance__lte=0.7).order_by('distance')
[<Author: Katy Stevens>, <Author: Stephen Keats>]
Please login to continue.