@property
    def deletable(self):
        return not Environment.objects.filter(elements__category=self).exists()


    # @@@ this protection should apply to queryset.delete as well
As per MutableSet.
dataset/ETHPy150Open mozilla/moztrap/moztrap/model/environments/models.py/Category.deletable--crossover with--dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/ordered_set.py/OrderedSet.add