TrigramBase
This class serves as a base for trigram-based database functions, calculating the similarity or distance between a field expression and a provided string. It automatically handles the conversion of raw string inputs into value expressions and ensures the result is returned as a floating-point field.
Attributes
| Attribute | Type | Description |
|---|---|---|
| output_field | [FloatField](../../../forms/fields/floatfield.md?sid=django_forms_fields_floatfield) = FloatField() | Defines the database type for the result of the trigram operation, defaulting to a FloatField to represent similarity scores or distances. |
Constructor
Signature
def TrigramBase(
expression: Any,
string: Any,
**extra: dict
)
Parameters
| Name | Type | Description |
|---|---|---|
| expression | Any | The field or expression to be evaluated. |
| string | Any | The string to compare against the expression. |
| **extra | dict | Additional keyword arguments for the function. |
Signature
def TrigramBase(
expression: [Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression),
string: str|Expression,
**extra: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| expression | [Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression) | The database column or expression to be compared. |
| string | `str | Expression` |
| **extra | dict | Additional keyword arguments for configuring the underlying database function, such as output_field or filter. |