diff --git a/readthedocs/core/signals.py b/readthedocs/core/signals.py index 07751426012..623a97e1900 100644 --- a/readthedocs/core/signals.py +++ b/readthedocs/core/signals.py @@ -81,6 +81,7 @@ def delete_projects_and_organizations(sender, instance, *args, **kwargs): # Here we count the owner list from the projects that the user own # Then exclude the projects where there are more than one owner # Add annotate before filter + # https://github.com/rtfd/readthedocs.org/pull/4577 # https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#order-of-annotate-and-filter-clauses # noqa projects = (Project.objects.annotate(num_users=Count('users')).filter(users=instance.id) .exclude(num_users__gt=1))