Skip to main content

A comprehensive Django package providing complete database of Uzbekistan's Regions, Districts & Quarters with multi-language support including Latin, Cyrillic, and Russian versions.

Project description

🌍 Uzbekistan

PyPI Version Django Version License Codecov status

A comprehensive Django package providing complete database of Uzbekistan's Regions, Districts & Quarters with multi-language support including Latin, Cyrillic, and Russian versions.

📊 Database Overview

  • Regions: 14
  • Regions/Cities: 205
  • Towns/Districts: 2,183+

✨ Features

  • Complete database of Uzbekistan's Regions, Districts & Quarters
  • Multi-language support:
    • Uzbek (Latin)
    • Uzbek (Cyrillic)
    • Russian
    • English
  • REST API endpoints
  • Configurable model activation
  • Built-in caching
  • Django Admin integration
  • JSON serialization methods on all models

🚀 Quick Start

Installation

pip install uzbekistan

Basic Setup

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    'uzbekistan',
]
  1. Configure in settings.py:
UZBEKISTAN = {
    'models': {
        'region': True,  # Enable Region model
        'district': True,  # Enable District model
        'village': True,  # Enable Village model
    },
    'views': {
        'region': True,  # Enable RegionListAPIView
        'district': True,  # Enable DistrictListAPIView
        'village': True,  # Enable VillageListAPIView
    },
    'cache': {
        'enabled': True,  # Enable caching
        'timeout': 3600,  # Cache timeout (1 hour)
        'key_prefix': "uzbekistan"  # Cache key prefix
    },
    "use_authentication": False  # Disable authentication for API views (if needed)
}
  1. Add URLs:
urlpatterns = [
    path('', include('uzbekistan.urls')),
]
  1. Run migrations (fixtures are loaded automatically on first migrate):
python manage.py makemigrations
python manage.py migrate

Data is seeded automatically after migration if the tables are empty. Re-running migrate will not reload data that already exists.

Management Commands

Command Description
python manage.py flush_uzbekistan Clear all Uzbekistan data (regions, districts, villages)
python manage.py flush_uzbekistan --no-input Clear without confirmation prompt

After flushing, the next migrate will re-seed the data automatically.

🔌 API Endpoints

Available Endpoints

Endpoint URL Pattern Name Description
Regions /regions region-list List all regions
Districts /districts/<int:region_id> district-list List districts for a specific region
Villages /villages/<int:district_id> village-list List villages for a specific district

Example Usage

# Get all regions
GET /regions

# Get districts for a specific region
GET /districts/1  # where 1 is the region_id

# Get villages for a specific district
GET /villages/1  # where 1 is the district_id

📋 JSON Serialization

All models provide an as_json() method for lightweight JSON-serializable output — useful outside of DRF views (e.g., management commands, Celery tasks, webhooks).

Region

region = Region.objects.get(pk=1)
region.as_json()
# {"id": 1, "name_uz": "Toshkent", "name_oz": "Тошкент", "name_ru": "Ташкент", "name_en": "Tashkent"}

District

district = District.objects.get(pk=1)

# Basic usage
district.as_json()
# {"id": 1, "name_uz": "Bekobod", "name_oz": "Бекобод", "name_ru": "Бекабад", "name_en": "Bekabad"}

# Include parent region
district.as_json(include_region=True)
# {"id": 1, "name_uz": "Bekobod", ..., "region": {"id": 1, "name_uz": "Toshkent", ...}}

Village

village = Village.objects.get(pk=1)

# Basic usage
village.as_json()
# {"id": 1, "name_uz": "Olmazar", "name_oz": "Олмазар", "name_ru": "Олмазар"}

# Include parent district
village.as_json(include_district=True)
# {"id": 1, ..., "district": {"id": 1, "name_uz": "Bekobod", ...}}

# Include both district and region
village.as_json(include_district=True, include_region=True)
# {"id": 1, ..., "district": {"id": 1, ..., "region": {"id": 1, ...}}}

🛠️ Development

Setup

# 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]"

Development Tools

  • Testing: pytest
  • Code Style:
    black --check uzbekistan/
    

📦 Release Process

Automated Release

  1. Update version:
python scripts/update_version.py 2.7.3
  1. Create and push tag:
git tag v2.7.3
git push origin v2.7.3

GitHub Actions will automatically:

  • Run tests
  • Build package
  • Publish to PyPI

Manual Release

# Build package
python -m build

# Check package
twine check dist/*

# Upload to PyPI
twine upload dist/*

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📄 License

This project is licensed under the MIT License - see LICENSE for details.

👤 Author

Jakhongir Ganiev - @ganiyevuz

🙏 Acknowledgments

  • All contributors who helped improve this package
  • Django and DRF communities for their excellent tools and documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uzbekistan-2.9.0.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uzbekistan-2.9.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file uzbekistan-2.9.0.tar.gz.

File metadata

  • Download URL: uzbekistan-2.9.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for uzbekistan-2.9.0.tar.gz
Algorithm Hash digest
SHA256 b38e61c94c53d9464300cb3968cc7b0693b3985db6024c1e3f35763a4389569a
MD5 d19a2577e9d9e0e1af4dfb8b2d9d62af
BLAKE2b-256 2188ed59d7087b1878b17ee9fc0311364b0655da053f9bf1115a8219570667e8

See more details on using hashes here.

File details

Details for the file uzbekistan-2.9.0-py3-none-any.whl.

File metadata

  • Download URL: uzbekistan-2.9.0-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for uzbekistan-2.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 785773517a4d257309e0c38ca00d6b522f377a0597860e3cd4c21b772be3106d
MD5 28c9e7eff4181f880224f52ce8928ccd
BLAKE2b-256 9afd757c93c4b34009c740655cab5d71ca74ca953798ed51b2696813e5510099

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page