diff --git a/apps/location/transfer_data.py b/apps/location/transfer_data.py index 885c47e0..e4ac90a7 100644 --- a/apps/location/transfer_data.py +++ b/apps/location/transfer_data.py @@ -1,3 +1,5 @@ +from django.db.models import Q + from transfer.serializers.location import CountrySerializer, RegionSerializer from transfer.models import Cities from pprint import pprint @@ -15,9 +17,7 @@ def transfer_countries(): def transfer_regions(): regions_without_subregion_queryset = Cities.objects.\ - exclude(subregion_code__isnull=True).\ - exclude(region_code__isnull=True).\ - exclude(country_code_2__isnull=True).\ + exclude(Q(subregion_code__isnull=False) | Q(region_code__isnull=True) | Q(country_code_2__isnull=True)).\ values('region_code', 'country_code_2', 'subregion_code').distinct() serialized_without_subregion = RegionSerializer(data=list(regions_without_subregion_queryset.values()), many=True)