### Setup Uzbekistan Development Environment Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Steps to clone the Uzbekistan repository, set up a virtual environment, and install development dependencies. This prepares the local environment for contributing to the package. ```bash # Clone repository git clone https://github.com/ganiyevuz/uzbekistan.git cd uzbekistan # Create virtual environment python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate # Install dependencies pip install -e ".[dev]" ``` -------------------------------- ### Uzbekistan API Endpoint Examples Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Demonstrates how to access the API endpoints provided by the Uzbekistan package to retrieve data on regions, districts, and villages. These examples show basic GET requests. ```http GET /regions GET /districts/1 GET /villages/1 ``` -------------------------------- ### Install Uzbekistan Django Package Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Installs the Uzbekistan Django package using pip. This is the first step to integrate the package into your Django project. ```bash pip install uzbekistan ``` -------------------------------- ### Backward Compatibility Functions Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Provides backward-compatible functions for simpler access to configuration settings, including checking model/view status, retrieving enabled items, and getting cache settings. ```APIDOC ## Backward Compatibility Functions ### Description Offers convenient functions for accessing configuration, ensuring compatibility with older versions or simpler usage patterns. ### Functions - **is_model_enabled(model_name: str) -> bool**: Checks if a model is enabled. - **is_view_enabled(view_name: str) -> bool**: Checks if a view is enabled. - **get_enabled_models() -> set[str]**: Returns a set of enabled model names. - **get_enabled_views() -> set[str]**: Returns a set of enabled view names. - **get_cache_settings() -> dict**: Returns cache settings as a dictionary. - **get_uzbekistan_setting(setting_name: str, default: any = None) -> any**: Retrieves a specific Uzbekistan setting with a default. - **validate_configuration()**: Validates the entire configuration. ### Request Example (Python) ```python from uzbekistan.dynamic_importer import ( is_model_enabled, get_enabled_models, get_cache_settings, get_uzbekistan_setting, validate_configuration ) if is_model_enabled('village'): print("Village model is active") models = get_enabled_models() print(f"Enabled models: {models}") cache = get_cache_settings() print(f"Cache timeout: {cache['timeout']}") try: validate_configuration() except Exception as e: print(f"Configuration error: {e}") ``` ### Response Example (Conceptual) ```json { "enabled_models": {"region", "district", "village"}, "enabled_views": {"region", "district", "village"}, "cache_settings": {"enabled": true, "timeout": 3600, "key_prefix": "uzbekistan"} } ``` ``` -------------------------------- ### Filter Villages via API and Python Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Provides examples for filtering village data using multiple parameters like name, district, and region identifiers via API or Python code. ```bash curl -X GET "http://localhost:8000/api/villages/150?name=olmazar" curl -X GET "http://localhost:8000/api/villages/150?region_name=tashkent&district_name=bekobod" ``` ```python from uzbekistan.filters import VillageFilterSet from uzbekistan.models import Village filterset = VillageFilterSet( data={'name': 'olmazar', 'region_id': 11}, queryset=Village.objects.select_related('district', 'district__region').all() ) filtered_villages = filterset.qs ``` -------------------------------- ### Manage Village Model Data in Django Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Provides examples for querying villages, filtering by parent district or region, and generating JSON representations with optional hierarchical parent data. ```python from uzbekistan.models import Village # Get all villages with optimized queries villages = Village.objects.select_related('district', 'district__region').all() # Search villages by name with filtering matching_in_region = Village.search_by_name("olmazar", region=region_instance) # JSON serialization with full hierarchy village_data_full = village.as_json(include_district=True, include_region=True) ``` -------------------------------- ### JSON Serialization for Region Model Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Shows how to use the `as_json()` method on a `Region` model instance to get a JSON-serializable representation of the region data, including multi-language names. ```python from uzbekistan.models import Region region = Region.objects.get(pk=1) print(region.as_json()) # Expected output: {"id": 1, "name_uz": "Toshkent", "name_oz": "Тошкент", "name_ru": "Ташкент", "name_en": "Tashkent"} ``` -------------------------------- ### GET /api/villages Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieves village data with support for full hierarchy serialization. ```APIDOC ## GET /api/villages ### Description Retrieves village data. Supports deep nesting of parent district and region information. ### Method GET ### Endpoint /api/villages ### Parameters #### Query Parameters - **district_id** (integer) - Optional - Filter by district. ### Response #### Success Response (200) - **id** (integer) - Unique identifier - **name_uz** (string) - Village name - **district** (object) - Parent district details #### Response Example { "id": 1200, "name_uz": "Olmazar", "district": { "id": 150, "name_uz": "Bekobod tumani" } } ``` -------------------------------- ### GET /api/districts Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieves district data with optional nested region information. ```APIDOC ## GET /api/districts ### Description Retrieves a list of districts. Can be filtered by name or region. ### Method GET ### Endpoint /api/districts ### Parameters #### Query Parameters - **name** (string) - Optional - Filter by district name. - **region_id** (integer) - Optional - Filter districts belonging to a specific region. ### Response #### Success Response (200) - **id** (integer) - Unique identifier - **name_uz** (string) - Name in Uzbek - **region** (object) - Optional nested region object if requested #### Response Example { "id": 150, "name_uz": "Bekobod tumani", "region": { "id": 11, "name_uz": "Toshkent viloyati" } } ``` -------------------------------- ### GET /api/villages/{district_id} Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieve all villages or quarters within a specific district ID. ```APIDOC ## GET /api/villages/{district_id} ### Description Returns all villages or quarters within a specific district identified by the district ID. ### Method GET ### Endpoint /api/villages/{district_id} ### Parameters #### Path Parameters - **district_id** (integer) - Required - The ID of the district to fetch villages for #### Query Parameters - **name** (string) - Optional - Filter villages by name ### Response #### Success Response (200) - **id** (integer) - Village ID - **name_uz** (string) - Name in Uzbek Latin - **district** (integer) - Associated district ID #### Response Example [ { "id": 1200, "name_uz": "Olmazar", "district": 150 } ] ``` -------------------------------- ### GET /api/districts/{region_id} Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieve all districts associated with a specific region ID. ```APIDOC ## GET /api/districts/{region_id} ### Description Returns all districts within a specific region identified by the region ID. ### Method GET ### Endpoint /api/districts/{region_id} ### Parameters #### Path Parameters - **region_id** (integer) - Required - The ID of the region to fetch districts for #### Query Parameters - **name** (string) - Optional - Filter districts by name within the region ### Response #### Success Response (200) - **id** (integer) - District ID - **name_uz** (string) - Name in Uzbek Latin - **region** (integer) - Associated region ID #### Response Example [ { "id": 150, "name_uz": "Bekobod tumani", "region": 11 } ] ``` -------------------------------- ### GET /api/regions Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieve a list of all 14 regions in Uzbekistan, with optional filtering by name across all supported languages. ```APIDOC ## GET /api/regions ### Description Returns all 14 regions of Uzbekistan with names in Uzbek Latin, Uzbek Cyrillic, Russian, and English. ### Method GET ### Endpoint /api/regions ### Parameters #### Query Parameters - **name** (string) - Optional - Filter regions by name (searches all language fields) ### Request Example GET /api/regions?name=tashkent ### Response #### Success Response (200) - **id** (integer) - Unique identifier - **name_uz** (string) - Name in Uzbek Latin - **name_oz** (string) - Name in Uzbek Cyrillic - **name_ru** (string) - Name in Russian - **name_en** (string) - Name in English #### Response Example [ { "id": 11, "name_uz": "Toshkent viloyati", "name_oz": "Тошкент вилояти", "name_ru": "Ташкентская область", "name_en": "Tashkent Region" } ] ``` -------------------------------- ### Manual Release: Build and Upload Package Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Steps for manually building the Python package and uploading it to PyPI using `build` and `twine`. This is an alternative to the automated release process. ```bash # Build package python -m build # Check package twine check dist/* # Upload to PyPI twine upload dist/* ``` -------------------------------- ### Run Django Migrations and Load Data Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Applies database migrations for the Uzbekistan package and loads initial data for regions and districts. This ensures the database schema is set up correctly and populated. ```bash python manage.py makemigrations python manage.py migrate python manage.py loaddata regions python manage.py loaddata districts ``` -------------------------------- ### Configure Django Admin Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Demonstrates how to enable automatic admin registration for models by updating the UZBEKISTAN settings dictionary in settings.py. ```python UZBEKISTAN = { 'models': { 'region': True, 'district': True, 'village': True, } } ``` -------------------------------- ### Use Backward Compatibility Functions Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Provides convenience functions for accessing configuration settings and validating the environment without direct class interaction. ```python from uzbekistan.dynamic_importer import ( is_model_enabled, get_enabled_models, get_cache_settings, validate_configuration ) if is_model_enabled('village'): print("Village model is active") cache_settings = get_cache_settings() validate_configuration() ``` -------------------------------- ### Filter Regions via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Demonstrates how to perform case-insensitive name searches across multiple language fields using the REST API. ```bash curl -X GET "http://localhost:8000/api/regions?name=samarkand" curl -X GET "http://localhost:8000/api/regions?name=самарканд" ``` -------------------------------- ### JSON Serialization for District Model Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Demonstrates the `as_json()` method for the `District` model, showing basic serialization and how to include parent region information. ```python from uzbekistan.models import District district = District.objects.get(pk=1) # Basic usage print(district.as_json()) # {"id": 1, "name_uz": "Bekobod", "name_oz": "Бекобод", "name_ru": "Бекабад", "name_en": "Bekabad"} # Include parent region print(district.as_json(include_region=True)) # {"id": 1, "name_uz": "Bekobod", ..., "region": {"id": 1, "name_uz": "Toshkent", ...}} ``` -------------------------------- ### Manage Dynamic Configuration Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Utilizes the DynamicImporter class to check enabled models/views, retrieve cache settings, and validate the application configuration. ```python from uzbekistan.dynamic_importer import DynamicImporter if DynamicImporter.is_model_enabled('region'): from uzbekistan.models import Region regions = Region.objects.all() enabled_models = DynamicImporter.get_enabled_models_list() cache_config = DynamicImporter.get_cache_config() DynamicImporter.validate_cache() ``` -------------------------------- ### Check Code Style with Black Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Uses the Black code formatter to check the code style of the Uzbekistan package. This command verifies if the code adheres to the project's formatting standards. ```bash black --check uzbekistan/ ``` -------------------------------- ### JSON Serialization for Village Model Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Illustrates the `as_json()` method for the `Village` model, including options to serialize with parent district and region data. ```python from uzbekistan.models import Village village = Village.objects.get(pk=1) # Basic usage print(village.as_json()) # {"id": 1, "name_uz": "Olmazar", "name_oz": "Олмазар", "name_ru": "Олмазар"} # Include parent district print(village.as_json(include_district=True)) # {"id": 1, ..., "district": {"id": 1, "name_uz": "Bekobod", ...}} # Include both district and region print(village.as_json(include_district=True, include_region=True)) # {"id": 1, ..., "district": {"id": 1, ..., "region": {"id": 1, ...}}} ``` -------------------------------- ### Include Uzbekistan URL Patterns Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Includes the Uzbekistan package's URL patterns into your project's urls.py. This makes the REST API endpoints accessible. ```python # urls.py from django.urls import path, include urlpatterns = [ path('api/', include('uzbekistan.urls')), ] ``` -------------------------------- ### Configure Uzbekistan Package in Django Settings Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Configures the Uzbekistan package by adding it to INSTALLED_APPS and defining settings in `settings.py`. This enables specific models, API views, and caching behavior. ```python INSTALLED_APPS = [ ... 'uzbekistan', ] UZBEKISTAN = { 'models': { 'region': True, 'district': True, 'village': True, }, 'views': { 'region': True, 'district': True, 'village': True, }, 'cache': { 'enabled': True, 'timeout': 3600, 'key_prefix': "uzbekistan" }, "use_authentication": False } ``` -------------------------------- ### Manage Region Model Data in Django Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Demonstrates how to query, search, and serialize Region model instances. It includes accessing related district data and exporting model data to JSON format. ```python from uzbekistan.models import Region # Get all regions regions = Region.objects.all() # Get a specific region by ID region = Region.objects.get(pk=14) print(region.name_uz) # "Toshkent shahri" # Search regions by name matching_regions = Region.search_by_name("ташкент") # JSON serialization region_data = region.as_json() # Access related districts districts = region.districts.all() ``` -------------------------------- ### JSON Serialization Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Details on how to use the `as_json()` method for serializing model data into JSON format. ```APIDOC ## JSON Serialization All models provide an `as_json()` method for lightweight JSON-serializable output. ### Region Serialization - **Method**: `Region.as_json()` - **Description**: Returns a JSON-serializable dictionary for a Region object. - **Example**: ```python region = Region.objects.get(pk=1) region.as_json() # Output: {"id": 1, "name_uz": "Toshkent", "name_oz": "Тошкент", "name_ru": "Ташкент", "name_en": "Tashkent"} ``` ### District Serialization - **Method**: `District.as_json(include_region=False)` - **Description**: Returns a JSON-serializable dictionary for a District object. Can optionally include parent region data. - **Parameters**: - **include_region** (bool) - Optional - If True, includes the parent region's data. - **Example**: ```python district = District.objects.get(pk=1) # Basic usage district.as_json() # Output: {"id": 1, "name_uz": "Bekobod", "name_oz": "Бекобод", "name_ru": "Бекабад", "name_en": "Bekabad"} # Include parent region district.as_json(include_region=True) # Output: {"id": 1, "name_uz": "Bekobod", ..., "region": {"id": 1, "name_uz": "Toshkent", ...}} ``` ### Village Serialization - **Method**: `Village.as_json(include_district=False, include_region=False)` - **Description**: Returns a JSON-serializable dictionary for a Village object. Can optionally include parent district and region data. - **Parameters**: - **include_district** (bool) - Optional - If True, includes the parent district's data. - **include_region** (bool) - Optional - If True, includes the parent region's data (only if `include_district` is also True). - **Example**: ```python village = Village.objects.get(pk=1) # Basic usage village.as_json() # Output: {"id": 1, "name_uz": "Olmazar", "name_oz": "Олмазар", "name_ru": "Олмазар"} # Include parent district village.as_json(include_district=True) # Output: {"id": 1, ..., "district": {"id": 1, "name_uz": "Bekobod", ...}} # Include both district and region village.as_json(include_district=True, include_region=True) # Output: {"id": 1, ..., "district": {"id": 1, ..., "region": {"id": 1, ...}}} ``` ``` -------------------------------- ### Filter Regions Programmatically Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Demonstrates how to use the RegionFilterSet to filter region data based on specific criteria using a Django queryset. ```python from uzbekistan.filters import RegionFilterSet from uzbekistan.models import Region filterset = RegionFilterSet(data={'name': 'tashkent'}, queryset=Region.objects.all()) filtered_regions = filterset.qs ``` -------------------------------- ### Manage District Model Data in Django Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Covers querying districts, performing optimized lookups with select_related, and serializing data with optional nested region information. ```python from uzbekistan.models import District, Region # Get districts with optimization districts = District.objects.select_related('region').filter(region_id=11) # Search districts by name matching = District.search_by_name("bekobod") # JSON serialization with nested parent region district_data_full = district.as_json(include_region=True) ``` -------------------------------- ### Dynamic Importer API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt The DynamicImporter class manages dynamic model and view loading based on settings configuration, providing methods to check enabled status, retrieve lists, and manage cache. ```APIDOC ## Dynamic Configuration Management ### Description Provides utilities for dynamically managing enabled models, views, and cache settings based on project configuration. ### Methods - **is_model_enabled(model_name: str) -> bool**: Checks if a specific model is enabled. - **is_view_enabled(view_name: str) -> bool**: Checks if a specific view is enabled. - **get_enabled_models_list() -> list[str]**: Returns a list of enabled model names. - **get_enabled_views_list() -> list[str]**: Returns a list of enabled view names. - **get_cache_config() -> CacheConfig**: Returns the cache configuration object. - **get_setting(setting_name: str, default: any = None) -> any**: Retrieves a specific setting with an optional default value. - **validate_cache()**: Validates the cache configuration. - **clear_cache()**: Clears internal caches. ### Request Example (Python) ```python from uzbekistan.dynamic_importer import DynamicImporter if DynamicImporter.is_model_enabled('region'): print("Region model is enabled") models = DynamicImporter.get_enabled_models_list() print(f"Enabled models: {models}") cache_config = DynamicImporter.get_cache_config() print(f"Cache enabled: {cache_config.enabled}") ``` ### Response Example (Conceptual) ```json { "enabled_models": ["region", "district", "village"], "enabled_views": ["region", "district", "village"], "cache_config": { "enabled": true, "timeout": 3600, "key_prefix": "uzbekistan" } } ``` ``` -------------------------------- ### Automated Release: Update Version and Tag Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Commands to update the package version and create a Git tag for a new release. This process is part of the automated release workflow triggered by GitHub Actions. ```bash python scripts/update_version.py 2.7.3 git tag v2.7.3 git push origin v2.7.3 ``` -------------------------------- ### Fetch All Regions via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieves all administrative regions of Uzbekistan through the REST API. The response includes region IDs and names in Uzbek Latin, Uzbek Cyrillic, Russian, and English. ```bash # Get all regions curl -X GET "http://localhost:8000/api/regions" # Response [ { "id": 1, "name_uz": "Qoraqalpog'iston Respublikasi", "name_oz": "Қорақалпоғистон Республикаси", "name_ru": "Республика Каракалпакстан", "name_en": "Republic of Karakalpakstan" }, { "id": 14, "name_uz": "Toshkent shahri", "name_oz": "Тошкент шаҳри", "name_ru": "Город Ташкент", "name_en": "Tashkent" } ] ``` -------------------------------- ### Filter Districts via API and Python Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Shows how to filter district data by name, region ID, or region name using both REST API requests and Python FilterSet classes. ```bash curl -X GET "http://localhost:8000/api/districts/11?name=chirchiq" curl -X GET "http://localhost:8000/api/districts/11?region_name=tashkent" ``` ```python from uzbekistan.filters import DistrictFilterSet from uzbekistan.models import District filterset = DistrictFilterSet( data={'name': 'bekobod', 'region_id': 11}, queryset=District.objects.select_related('region').all() ) filtered_districts = filterset.qs ``` -------------------------------- ### Include Uzbekistan URLs in Django Project Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md Includes the URL patterns provided by the Uzbekistan package into your Django project's main `urls.py`. This makes the package's API endpoints accessible. ```python from django.urls import path, include urlpatterns = [ path('', include('uzbekistan.urls')), ] ``` -------------------------------- ### API Endpoints Source: https://github.com/ganiyevuz/uzbekistan/blob/master/README.md This section details the available REST API endpoints for accessing Uzbekistan's geographical data. ```APIDOC ## API Endpoints ### Regions - **Method**: GET - **Endpoint**: `/regions` - **Description**: List all regions in Uzbekistan. - **Response Example**: ```json [ {"id": 1, "name_uz": "Toshkent", "name_oz": "Тошкент", "name_ru": "Ташкент", "name_en": "Tashkent"} ] ``` ### Districts by Region - **Method**: GET - **Endpoint**: `/districts/` - **Description**: List districts for a specific region. - **Path Parameters**: - **region_id** (int) - Required - The ID of the region to retrieve districts for. - **Response Example**: ```json [ {"id": 1, "name_uz": "Bekobod", "name_oz": "Бекобод", "name_ru": "Бекабад", "name_en": "Bekabad"} ] ``` ### Villages by District - **Method**: GET - **Endpoint**: `/villages/` - **Description**: List villages for a specific district. - **Path Parameters**: - **district_id** (int) - Required - The ID of the district to retrieve villages for. - **Response Example**: ```json [ {"id": 1, "name_uz": "Olmazar", "name_oz": "Олмазар", "name_ru": "Олмазар"} ] ``` ``` -------------------------------- ### Fetch Villages by District ID via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieves all villages or quarters within a specific district, identified by its district ID. The response includes village names and the associated district ID. ```bash # Get villages for a specific district (district_id=150) curl -X GET "http://localhost:8000/api/villages/150" # Response [ { "id": 1200, "name_uz": "Olmazar", "name_oz": "Олмазар", "name_ru": "Олмазар", "district": 150 }, { "id": 1201, "name_uz": "Yangi hayot", "name_oz": "Янги ҳаёт", "name_ru": "Янги хаёт", "district": 150 } ] ``` -------------------------------- ### Filter Villages by Name via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Filters villages based on a provided name query. This enables searching for specific villages within a district or across the dataset. ```bash # Filter villages by name curl -X GET "http://localhost:8000/api/villages/150?name=olmazar" ``` -------------------------------- ### Django Admin Integration Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt The package automatically registers admin classes for enabled models, providing search, filtering, and sorting capabilities directly within the Django admin interface. ```APIDOC ## Django Admin Integration ### Description Automatically registers admin interfaces for enabled models, offering enhanced management capabilities through the Django admin site. ### Configuration Admin classes are automatically registered based on the `UZBEKISTAN` setting in `settings.py`. ### Example `settings.py` ```python UZBEKISTAN = { 'models': { 'region': True, # Enables RegionAdmin 'district': True, # Enables DistrictAdmin 'village': True, # Enables VillageAdmin }, # ... other settings } ``` ### Accessing Admin Admin interfaces are accessible at URLs like `/admin/uzbekistan/region/`, `/admin/uzbekistan/district/`, etc., provided the corresponding models are enabled. ### RegionAdmin Features - **List Display**: `name_uz`, `name_oz`, `name_ru`, `name_en`, `district_count` - **Searchable Fields**: All `name` fields (e.g., `name_uz`, `name_oz`, etc.) - **Filtering and Sorting**: Available for list display fields. ``` -------------------------------- ### Fetch Districts by Region ID via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Retrieves all districts belonging to a specific region, identified by its region ID. The response includes district details and the associated region ID. ```bash # Get districts for Tashkent Region (region_id=11) curl -X GET "http://localhost:8000/api/districts/11" # Response [ { "id": 150, "name_uz": "Bekobod tumani", "name_oz": "Бекобод тумани", "name_ru": "Бекабадский район", "name_en": "Bekabad District", "region": 11 }, { "id": 151, "name_uz": "Bo'stonliq tumani", "name_oz": "Бўстонлиқ тумани", "name_ru": "Бостанлыкский район", "name_en": "Bostanliq District", "region": 11 } ] ``` -------------------------------- ### Filter Regions by Name via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Filters regions based on a provided name query, searching across all supported language fields. This allows for targeted retrieval of specific regions. ```bash # Filter regions by name (searches all language fields) curl -X GET "http://localhost:8000/api/regions?name=tashkent" # Response [ { "id": 11, "name_uz": "Toshkent viloyati", "name_oz": "Тошкент вилояти", "name_ru": "Ташкентская область", "name_en": "Tashkent Region" }, { "id": 14, "name_uz": "Toshkent shahri", "name_oz": "Тошкент шаҳри", "name_ru": "Город Ташкент", "name_en": "Tashkent" } ] ``` -------------------------------- ### Village Filtering API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Filter villages by name, district ID, district name, region ID, or region name. Allows for complex filtering across multiple criteria. ```APIDOC ## GET /api/villages/{id} ### Description Retrieves a list of villages, optionally filtered by name, district ID, district name, region ID, or region name. ### Method GET ### Endpoint `/api/villages/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the district to filter villages within. #### Query Parameters - **name** (string) - Optional - Search village names (all languages). - **district_id** (integer) - Optional - Filter by district ID. - **district_name** (string) - Optional - Filter by district name (all languages). - **region_id** (integer) - Optional - Filter by region ID. - **region_name** (string) - Optional - Filter by region name (all languages). ### Request Example ```bash curl -X GET "http://localhost:8000/api/villages/150?name=olmazar" curl -X GET "http://localhost:8000/api/villages/150?region_name=tashkent&district_name=bekobod" ``` ### Response #### Success Response (200) - **villages** (array) - A list of village objects matching the filter criteria. - **id** (integer) - The village ID. - **name** (string) - The village name. - **district_id** (integer) - The ID of the district the village belongs to. #### Response Example ```json { "villages": [ { "id": 1, "name": "Olmazar", "district_id": 150 } ] } ``` ``` -------------------------------- ### District Filtering API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Filter districts by name, region ID, or region name. Supports searching district names across all languages and filtering by region details. ```APIDOC ## GET /api/districts/{id} ### Description Retrieves a list of districts, optionally filtered by name, region ID, or region name. ### Method GET ### Endpoint `/api/districts/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the region to filter districts within. #### Query Parameters - **name** (string) - Optional - Search district names (all languages). - **region_id** (integer) - Optional - Filter by region ID. - **region_name** (string) - Optional - Filter by region name (all languages). ### Request Example ```bash curl -X GET "http://localhost:8000/api/districts/11?name=chirchiq" curl -X GET "http://localhost:8000/api/districts/11?region_name=tashkent" ``` ### Response #### Success Response (200) - **districts** (array) - A list of district objects matching the filter criteria. - **id** (integer) - The district ID. - **name** (string) - The district name. - **region_id** (integer) - The ID of the region the district belongs to. #### Response Example ```json { "districts": [ { "id": 1, "name": "Chirchiq", "region_id": 11 } ] } ``` ``` -------------------------------- ### Filter Districts by Name within a Region via REST API Source: https://context7.com/ganiyevuz/uzbekistan/llms.txt Filters districts within a specific region based on a name query. This allows for precise searching of districts within a given administrative area. ```bash # Filter districts by name within a region curl -X GET "http://localhost:8000/api/districts/11?name=chirchiq" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.