1👍
One idea to avoid this happening is to "switch" the default condition and use Q() instead of ~Q()
.annotate(
employee_authorized=Case(
When(Q(case__assigned_unit__in=[]), then=Value(True)),
default=Value(False),
output_field=BooleanField(),
)
)
Source:stackexchange.com