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.
Metadata
Release files for django-sifen-catalogs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_sifen_catalogs-0.1.0.tar.gz | 84.9 kB | With provenance | Details for django_sifen_catalogs-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_sifen_catalogs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for django_sifen_catalogs-0.1.0-py3-none-any.whl |
Total release size: 168.2 kB
Release files / django_sifen_catalogs-0.1.0.tar.gz
| Download URL | django_sifen_catalogs-0.1.0.tar.gz |
|---|---|
| Size | 84.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5123ca704094a268e54d7af4466b7c50ec058d51dc58cb3bb62e6f0aa75dcd1f
|
|
BLAKE2b-256 checksum How to use checksums |
07f98abe1abb2da61f0cb8960a5aef331641fbb97199b8848fa27c2d954fb419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency logRelease files / django_sifen_catalogs-0.1.0-py3-none-any.whl
| Download URL | django_sifen_catalogs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 83.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e62b2cd2d85f220bcf993f28cf5c2d6a0566373733a38a0fc2569fcb731d94f9
|
|
BLAKE2b-256 checksum How to use checksums |
47ee822009a28d607d4be25861a131b9e1b57fab1c3b938b7febd0529f7d555a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency logSecurity for django-sifen-catalogs 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_sifen_catalogs-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.