Django: list of valid field search operators

Does Django have a list of available field search operators (those used by the QuerySet API, for example, "contains", "in", "lt", etc.)?

thank

EDIT: for clarification, I mean a list in the code that I can import, for example, I can check if a given string matches a valid statement.

+4
source share
4 answers

After searching for a source for operators, he lives in django.db.models.sql.constants.QUERY_TERMS.

A dictionary with search strings matched with None.

'exact' in QUERY_TERMS

Thanks for this! I would never have looked, but I could definitely use it.

+8
source

your_model._meta.fields[index].class_lookups

.

0

Starting with Django 2.1, the constant is django.db.models.sql.constants.QUERY_TERMSremoved. According to the release notes , Django recommends an alternative to the search registration API method .get_lookups()

For a given field in the model, it can be accessed through:

MyModel._meta.get_field('my_field').get_lookups()
0
source

All Articles