I implemented this feature by having a default manager that overrides 
get_queryset. it loops over any calculated field declared on the model and 
annotates that model. Always.

The main issue I ran into is that these fields were not query-able when 
used for related lookups.

So:

Customer.objects.filter(is_adult=True) worked fine.

But Orders.objects.filter(customer__is_adult=True) did not, because these 
related queries did *not* go through the objects.get_queryset we know and 
love.

So if this addition could handle these cases, it'd be great.

Otherwise, it can already be done by just providing a 
"CalculatedFieldManager" and assigning that to your model.

On Monday, November 20, 2017 at 10:31:31 PM UTC-5, ilya.ka...@jetbrains.com 
wrote:
>
> Thank you all.
>
> I've created a feature request https://code.djangoproject.com/ticket/28822 
> and 
> will try to implement in my Django fork next week. I am not Django source 
> code guru, so any help is welcome:)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ef8fc778-a4b4-4d39-a07d-fb329a19c4ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to