def _fetch_content_type_counts(self):
        """
        If an object with an empty _ct_inventory is encountered, compute all
        the content types currently used on that object and save the list in
        the object itself. Further requests for that object can then access
        that information and find out which content types are used without
        resorting to multiple selects on different ct tables.

        It is therefore important that even an "empty" object does not have an
        empty _ct_inventory.
        """

        if "counts" not in self._cache:
            if (
                self.item._ct_inventory
                and self.item._ct_inventory.get("_version_", -1) == INVENTORY_VERSION
            ):
                try:
                    self._cache["counts"] = self._from_inventory(
                        self.item._ct_inventory
                    )
                except KeyError:
                    # It's possible that the inventory does not fit together
                    # with the current models anymore, f.e. because a content
                    # type has been removed.
                    pass

            if "counts" not in self._cache:
                super()._fetch_content_type_counts()

                self.item._ct_inventory = self._to_inventory(self._cache["counts"])

                self.item.__class__.objects.filter(id=self.item.id).update(
                    _ct_inventory=self.item._ct_inventory
                )

                # Run post save handler by hand
                if hasattr(self.item, "get_descendants"):
                    self.item.get_descendants(include_self=False).update(
                        _ct_inventory=None
                    )
        return self._cache["counts"]

        If an object with an empty _ct_inventory is encountered, compute all
        the content types currently used on that object and save the list in
        the object itself. Further requests for that object can then access
        that information and find out which content types are used without
        resorting to multiple selects on different ct tables.

        It is therefore important that even an "empty" object does not have an
        empty _ct_inventory.
        
feincms/extensions/ct_tracker.py