@task(ignore_result=True)
def remove_empty_groups():
 from mozillians.groups.models import Group, Skill
 for model in [Group, Skill]:
  model.objects.annotate(mcount=Count('members')).filter(mcount=0).delete()

@ task ( ignore_result = True ) def remove_empty_groups ( ) : from mozillians . groups . models import Group , Skill for model in [ Group , Skill ] : model . objects . annotate ( mcount = Count ( 'members' ) ) . filter ( mcount = 0 ) . delete ( )
remove empty groups .