A comprehensive Django package providing complete database of Uzbekistan's Regions, Districts & Quarters with multi-language support including Latin, Cyrillic, and Russian versions.
- Regions: 14
- Regions/Cities: 205
- Towns/Districts: 2,183+
- 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
pip install uzbekistan- Add to
INSTALLED_APPS:
INSTALLED_APPS = [
...
'uzbekistan',
]- 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)
}- Add URLs:
urlpatterns = [
path('', include('uzbekistan.urls')),
]- Run migrations (fixtures are loaded automatically on first migrate):
python manage.py makemigrations
python manage.py migrateData is seeded automatically after migration if the tables are empty. Re-running
migratewill not reload data that already exists.
| 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.
| 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 |
# 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_idAll 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.objects.get(pk=1)
region.as_json()
# {"id": 1, "name_uz": "Toshkent", "name_oz": "Тошкент", "name_ru": "Ташкент", "name_en": "Tashkent"}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.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, ...}}}# 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]"- Testing:
pytest - Code Style:
black --check uzbekistan/
- Update version:
python scripts/update_version.py 2.7.3- Create and push tag:
git tag v2.7.3
git push origin v2.7.3GitHub Actions will automatically:
- Run tests
- Build package
- Publish to PyPI
# Build package
python -m build
# Check package
twine check dist/*
# Upload to PyPI
twine upload dist/*- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see LICENSE for details.
Jakhongir Ganiev - @ganiyevuz
- All contributors who helped improve this package
- Django and DRF communities for their excellent tools and documentation