'Adding custom expression in values() in Django for postgresql Database

As per official Django docs for values() ,

The values() method also takes optional keyword arguments, **expressions, which are passed through to annotate()

I wants to get result of "ts_rank_cd(textsearch, query) AS rank" as column as postgresql is getting here : https://www.postgresql.org/docs/9.6/textsearch-controls.html

So my question, can I get similar column result in Django, using it's values() method and **expressions . Also I didn't found any example in net which uses values() function with **expressions argument. Please help in explaining how to use this argument, and can this will solve my issue?

For safer side, I wants to use as much Django's inbuild function as possible for security purpose.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source