Suor / django-cacheops

A slick ORM cache with automatic granular event-driven invalidation.
BSD 3-Clause "New" or "Revised" License
2.1k stars 227 forks source link

`invalidate_m2o` and polymorphic models #431

Closed aletor123 closed 1 year ago

aletor123 commented 2 years ago

Now there is problem with polymorphic models and invalidate_m2o. When Model is inherited it's pk field is OneToOne field to parent model. And if there is some other model with FK to inherited model, this FK points to OneToOne field. In this situation getattr(instance, f.field_name) will return model instance of parent model, when we need to get id.

Pull request: https://github.com/Suor/django-cacheops/pull/430