Using F() through function

Dear,
Query set as below work:
Model.objects.filter(...).annotate(NewId=F('id'))
But using F through function not work:
Model.objects.filter(...).annotate(NewId=SomeFunction(F('id')))
or
Model.objects.filter(...).annotate(NewId=Value(SomeFunction(F('id'))))

Hi, please format your code properly in order to better understand it.

In Django, F expressions represent database fields and allow you to refer to model fields directly in database queries. Read this: Query Expressions | Django documentation | Django
.

1 Like