Re: using .annotate on a queryset and output field is a result of function

2021-06-28 Thread VISHESH MANGLA
this looks good, thanks On Thu, Jun 17, 2021 at 6:08 PM Nikeet NA wrote: > Its not the perfect method you can optimize ot more if you want. > You can prefer this Link > > > On Thu, 17 Jun 2021 at 18:06, Nikeet NA wrote:

Re: using .annotate on a queryset and output field is a result of function

2021-06-17 Thread Nikeet NA
Its not the perfect method you can optimize ot more if you want. You can prefer this Link On Thu, 17 Jun 2021 at 18:06, Nikeet NA wrote: > You can do it like this : > > class TransactionEntry(models.Manager): >de

Re: using .annotate on a queryset and output field is a result of function

2021-06-17 Thread Nikeet NA
You can do it like this : class TransactionEntry(models.Manager): def get_total_prices(self): return self.queryset().defer("users").annotate.(total_price=F("num_shares")*F("price_per_share")) On Thu, 17 Jun 2021 at 15:31, VISHESH MANGLA < f20170...@pilani.bits-pilani.ac.in> wr

Re: using .annotate on a queryset and output field is a result of function

2021-06-17 Thread VISHESH MANGLA
what about overwriting the manager? How to make the manager auto-add those computed properties ? On Thursday, June 17, 2021 at 8:50:27 AM UTC+5:30 Nikeet NA wrote: > You cannot use properties in django orm , it does not allow that. > > TransactionEntry.objects.defer("users").annotate(total_pric

Re: using .annotate on a queryset and output field is a result of function

2021-06-16 Thread Nikeet NA
You cannot use properties in django orm , it does not allow that. TransactionEntry.objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share")).values('total_price') On Thursday, 17 June 2021 at 03:23:01 UTC+5:30 VISHESH MANGLA wrote: > Hello, > > I wanted to know that how fo

using .annotate on a queryset and output field is a result of function

2021-06-16 Thread VISHESH MANGLA
Hello, I wanted to know that how for the model below, how can I get a queryset with all the fields excluding the `user` and including the output of get_output_field? Please avoid hardcoding. One way is `TransactionEntry .objects.defer("users").annotate(total_price=F("num_shares")*F("price_p