Update country serializer

This commit is contained in:
littlewolf 2019-10-26 08:42:00 +03:00
parent abe8eae655
commit e72e92244b

View File

@ -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)