django-sifen-catalogs
Official SIFEN geographic location catalogs for Django: departments, districts, cities, and neighborhoods in Paraguay.
The package ships a CSV catalog derived from DNIT's Código de Referencia Geográfica and provides Django models plus an idempotent import command. Runtime dependencies are limited to Django.
Scope
This release covers geographic locations only:
Department → District → City → Neighborhood
Each level uses official SIFEN numeric codes (sifen_code). Neighborhood data is included when present in the official catalog; other catalog types remain out of scope.
Current bundled catalog counts: 18 departments, 272 districts, 6,766 cities/localities, 1,104 neighborhoods (7,735 CSV rows).
Geographic hierarchy
The package preserves the geographic classification published in the official DNIT SIFEN catalog:
Department → District → City / Locality → Neighborhood
City represents the official City / Locality field from the DNIT catalog.
Some entries may have names that appear to describe neighborhoods or urban
subdivisions. These entries are intentionally preserved as City / Locality
records because their codes and classification are part of the official SIFEN
reference data.
Neighborhood records are created only when the official catalog provides
values in the corresponding neighborhood fields.
The package does not reinterpret or normalize the official geographic classification.
Installation
pip install django-sifen-catalogs
Django setup
Add the app to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_sifen_catalogs.apps.LocationsConfig",
]
Run migrations:
python manage.py migrate locations
Import the bundled catalog:
python manage.py import_sifen_locations
Import a custom CSV with the same columns:
python manage.py import_sifen_locations --file /path/to/locations.csv
Import semantics
- Custom
--fileinput is expected to follow the same column layout and integrity assumptions as the package's generatedlocations.csv. - Import is upsert-only: it creates or updates rows from the CSV and does not remove catalog entries that disappear in a future DNIT release.
- Re-import updates official names and parent relationships, but preserves each
row's current
is_activevalue. New rows default to active. - In dependent admin autocompletes, neighborhood choices may be empty when the selected official city/locality has no barrio rows in the DNIT catalog.
Models
Hierarchy: Department → District → City → Neighborhood
| Model | Key fields |
|---|---|
Department |
sifen_code, name, is_active |
District |
sifen_code, name, department, is_active |
City |
sifen_code, name, district, is_active |
Neighborhood |
sifen_code, name, city, is_active |
Example:
from django_sifen_catalogs.models import City, Department, District, Neighborhood
central = Department.objects.get(sifen_code=12)
lambare_district = District.objects.get(sifen_code=169)
lambare_city = City.objects.get(sifen_code=6106)
kennedy = Neighborhood.objects.get(sifen_code=179)
Each lookup is model-scoped. The same numeric value can appear at different
levels in the official DNIT catalog (for example, city code 1 and neighborhood
code 1 are different records in different tables).
Model __str__ values use friendly names only (for example, City — District, Neighborhood — City). SIFEN codes are exposed in admin and search fields instead.
Stable identifiers
Use sifen_code as the interoperable identifier for a specific catalog model.
Codes are unique within each model (Department, District, City,
Neighborhood), not globally across all location types. Always resolve a code
through the intended model, for example City.objects.get(sifen_code=6107) or
Neighborhood.objects.get(sifen_code=1).
Local primary keys are not part of the public contract.
App label compatibility
| Concept | Value |
|---|---|
| Python package | django_sifen_catalogs |
| Django app label | locations |
| Database tables | locations_department, locations_district, locations_city, locations_neighborhood |
| Foreign key strings | "locations.City", "locations.District", "locations.Department", "locations.Neighborhood" |
The app label locations is kept for compatibility with existing integrations.
Internationalization
Model, field, and import-command UI labels use Django i18n with English source strings. Spanish translations ship in django_sifen_catalogs/locale/es/LC_MESSAGES/django.mo.
The package respects the host project's LANGUAGE_CODE and LocaleMiddleware. It does not define its own language setting, and official DNIT catalog names stored in the database are never translated.
Maintainers can refresh translations with:
django-admin makemessages -l es
django-admin compilemessages -l es
Catalog provenance and updates
Bundled data files:
django_sifen_catalogs/data/locations.csvdjango_sifen_catalogs/data/PROVENANCE.md
The official DNIT XLS/XLSX spreadsheet is not included in the wheel. Maintainers regenerate the CSV with:
python scripts/update_sifen_catalog.py /path/to/oficial.xlsx
Workflow: download the latest official file → run the script → review the CSV diff → release a new package version. See PROVENANCE.md for source details and the non-endorsement note.
Admin
Catalog admins protect official structure: add and delete are disabled,
sifen_code, names, and parent relationships are read-only, and only
is_active is editable (including from the changelist). The host project must
include django.contrib.admin.
Optional integration: dependent admin autocomplete
If your project model stores a location hierarchy, you can wire dependent admin autocompletes with django-admin-dependent-autocomplete (optional; not a runtime dependency of this package):
from django.contrib import admin
from django.db import models
from django_admin_dependent_autocomplete.admin import DependentAutocompleteAdminMixin
from django_sifen_catalogs.models import City, Department, District, Neighborhood
class Customer(models.Model):
department = models.ForeignKey(Department, on_delete=models.PROTECT)
district = models.ForeignKey(District, on_delete=models.PROTECT)
city = models.ForeignKey(City, on_delete=models.PROTECT)
neighborhood = models.ForeignKey(Neighborhood, on_delete=models.PROTECT, blank=True, null=True)
@admin.register(Customer)
class CustomerAdmin(DependentAutocompleteAdminMixin, admin.ModelAdmin):
autocomplete_fields = ["district", "city", "neighborhood"]
autocomplete_dependencies = {
"district": "department",
"city": "district",
"neighborhood": "city",
}
This package registers structure-protected catalog admins with search_fields
for Department, District, City, and Neighborhood.
Demo
A minimal Django Admin demo lives in testapp/ (development only; not shipped in the package wheel).
pip install -e ".[dev]"
python testapp/manage.py migrate
python testapp/manage.py import_sifen_locations
python testapp/manage.py create_demo_superuser
python testapp/manage.py runserver
Open http://127.0.0.1:8000/admin/ and sign in with admin / admin.
The demo registers structure-protected catalog admins for departments, districts,
cities/localities, and neighborhoods, plus an Address model that uses
django-admin-dependent-autocomplete
for nested location selection. Neighborhood autocomplete stays empty for
city/locality records that have no official barrio data in the DNIT catalog.
Development
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
ruff check .
python -m build
twine check dist/*
Requirements
- Python >= 3.8
- Django >= 3.2, < 6.0
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_sifen_catalogs-0.1.0.tar.gz.
File metadata
- Download URL: django_sifen_catalogs-0.1.0.tar.gz
- Upload date:
- Size: 84.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5123ca704094a268e54d7af4466b7c50ec058d51dc58cb3bb62e6f0aa75dcd1f
|
|
| MD5 |
3bcd9d7e7690e62c2b2a346374f1ccfc
|
|
| BLAKE2b-256 |
07f98abe1abb2da61f0cb8960a5aef331641fbb97199b8848fa27c2d954fb419
|
Provenance
The following attestation bundles were made for django_sifen_catalogs-0.1.0.tar.gz:
Publisher:
release.yml on JuanBer90/django-sifen-catalogs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_sifen_catalogs-0.1.0.tar.gz -
Subject digest:
5123ca704094a268e54d7af4466b7c50ec058d51dc58cb3bb62e6f0aa75dcd1f - Sigstore transparency entry: 2568880989
- Sigstore integration time:
-
Permalink:
JuanBer90/django-sifen-catalogs@635fd2f266fd5c2c6726a02db263fe3aa272e5ff -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JuanBer90
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@635fd2f266fd5c2c6726a02db263fe3aa272e5ff -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_sifen_catalogs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_sifen_catalogs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 83.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e62b2cd2d85f220bcf993f28cf5c2d6a0566373733a38a0fc2569fcb731d94f9
|
|
| MD5 |
3d58fcccfa162b1defb505ab082b6007
|
|
| BLAKE2b-256 |
47ee822009a28d607d4be25861a131b9e1b57fab1c3b938b7febd0529f7d555a
|
Provenance
The following attestation bundles were made for django_sifen_catalogs-0.1.0-py3-none-any.whl:
Publisher:
release.yml on JuanBer90/django-sifen-catalogs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_sifen_catalogs-0.1.0-py3-none-any.whl -
Subject digest:
e62b2cd2d85f220bcf993f28cf5c2d6a0566373733a38a0fc2569fcb731d94f9 - Sigstore transparency entry: 2568880994
- Sigstore integration time:
-
Permalink:
JuanBer90/django-sifen-catalogs@635fd2f266fd5c2c6726a02db263fe3aa272e5ff -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JuanBer90
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@635fd2f266fd5c2c6726a02db263fe3aa272e5ff -
Trigger Event:
push
-
Statement type: