M
M
Michael2017-09-06 03:27:57
Django
Michael, 2017-09-06 03:27:57

How to implement a query in the database with a count of the number of words?

Hello, the bottom line is this.
The table has a column that stores words separated by spaces. Example: Vasya Petya word phrase
You need to make a query using the django ORM that will select records based on the number of words in this column.
As I think to implement, first you need to count the number of words in the column, and then select those records that are equal to the desired number and then a stupor. I can not implement both counting and comparison at the same time.
Model.objects.filter (we count the number of words in the column = 2)
I assume that you need to use Func, but the request itself is not clear.
Help me please.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question