1

One of my models contains a @cached_property. When I query this model and filter the results, the cached property is not available. However, if I isolate a single instance in the queryset, I can access the cached property. How can I filter the entire queryset based on the value of the cached property?

django.core.exceptions.FieldError: Cannot resolve keyword 'my_cached_property' into field.

Mike
  • 785
  • 1
  • 6
  • 14
  • 2
    from official doc[link](https://docs.djangoproject.com/en/2.1/ref/utils/#django.utils.functional.cached_property) seems like cached_property is a run time generated property of model instance and django query_set is lazily evaluated, doesn’t actually query the database until it’s result is accessed. So i don't think is actually possible in `db-level`. Need to be done with manual effort through a loop. – Shakil Mar 30 '19 at 16:12
  • 2
    Thanks @Shakil, your answer helped point me in the right direction, as did this: https://stackoverflow.com/questions/18255290/how-to-create-an-empty-queryset-and-to-add-objects-manually-in-django/30359049 – Mike Mar 30 '19 at 17:14

0 Answers0