fix configs

This commit is contained in:
Kuroshini 2020-01-23 18:02:12 +03:00
parent f9c5bdceee
commit 6d2aee572a
2 changed files with 5 additions and 8 deletions

View File

@ -80,22 +80,19 @@ class RegionQuerySet(models.QuerySet):
def without_parent_region(self, switcher: bool = True):
"""Filter regions by parent region."""
return self.filter(parent_region__isnull=switcher)\
.order_by('code')
return self.filter(parent_region__isnull=switcher)
def by_region_id(self, region_id):
"""Filter regions by region id."""
return self.filter(id=region_id)\
.order_by('code')
return self.filter(id=region_id)
def by_sub_region_id(self, sub_region_id):
"""Filter sub regions by sub region id."""
return self.filter(parent_region_id=sub_region_id)\
.order_by('code')
return self.filter(parent_region_id=sub_region_id)
def sub_regions_by_region_id(self, region_id):
"""Filter regions by sub region id."""
return self.filter(parent_region_id=region_id).order_by('code')
return self.filter(parent_region_id=region_id)
class Region(models.Model):

View File

@ -18,7 +18,7 @@ class CountryViewMixin(generics.GenericAPIView):
class RegionViewMixin(generics.GenericAPIView):
"""View Mixin for model Region"""
model = models.Region
queryset = models.Region.objects.all()
queryset = models.Region.objects.all().order_by('name')
class CityViewMixin(generics.GenericAPIView):