D
D
Dobby Free2016-12-07 18:47:03
Django
Dobby Free, 2016-12-07 18:47:03

How to exclude all columns of a table from a query?

As we defined in the previous topic , I need a query like Model.objects.filter(q).values('column').annotate(Count('column')). Now actually the main problem is that this query gets a column that I don't need from the database. I need to get only count, without this column. How to remake this query so that it does not take the column from the database?
P.S. I suspect that values('column') is basically redundant here. But if this is removed, then all the data in the table is loaded in general. In general, I need not to load a single column, but only a count request.
P.S. Some sort of defer('*') is needed. Too bad it doesn't work like that. :( And listing the names of all columns is not an option. Suddenly I will change the structure of the table ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iegor, 2016-12-07
@FreeDobby

Use values() or value_list()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question