1. Jannis Leidel
  2. johnny-cache

Commits

Jeremy Self  committed e94376a

adding code from panni in issue #32 (thanks)

  • Participants
  • Parent commits 6cdb664
  • Branches default

Comments (0)

Files changed (1)

File johnny/cache.py

View file
  • Ignore whitespace
         if self._patched:
             self.keyhandler.invalidate_table(instance._meta.db_table)
 
+            tables = set()
+            tables.add(instance._meta.db_table)
+            self.keyhandler.invalidate_table(instance._meta.db_table)
+
+            for obj in instance._meta._related_objects_cache.keys():
+                obj_table = obj.model._meta.db_table
+                if obj_table not in tables:
+                    tables.add(obj_table)
+                    self.keyhandler.invalidate_table(obj_table)
+
     def _handle_signals(self):
         post_save.connect(self.invalidate, sender=None)
         post_delete.connect(self.invalidate, sender=None)