In Django, is there a way to set field values with a query expression on objects returned from a queryset?

348 Views Asked by At

I have a proxy model which has to have some calculated (with query expressions) read-only fields. Annotating won't do, because I will later need to have field metadata to do filtering in my views.

So, is there a way to call a SQL function to get the value?

I am looking for something like a QuerySet.annotate for fields, a Transform or a custom field that would do this.

1

There are 1 best solutions below

1
On BEST ANSWER

I found a way to do this by using the Col Expression and a custom field.