osmflex
A Django app that mirrors pgosm-flex output, giving you an ORM-shaped view of OpenStreetMap data imported via osm2pgsql.
Stack
- Python 3.11+
- Django 5.2 LTS
- PostGIS 16-3.4+
- Package managed with uv
Install
uv add osmflex
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...,
"django.contrib.gis",
"osmflex",
]
Import OSM data
osmflex ships two management commands:
./manage.py run_osm2pgsql /path/to/foo.osm.pbf # writes schema osm.*
./manage.py import_from_pgosmflex --truncate # upserts into osmflex_*
Then query with the Django ORM:
>>> from osmflex.models import AmenityPoint
>>> AmenityPoint.objects.count()
14827
>>> AmenityPoint.objects.tagged()[:5] # annotates each row with the full OSM tag JSONB
End-to-end runnable example: examples/minimal_import/
walks through fetching a Geofabrik extract and running the full pipeline in a
disposable PostGIS container. Try:
cd examples/minimal_import
make db-up install migrate pbf import psql
Docs
docs/architecture.md— the pgosm-flex → Django pipeline, taxonomy, SRID choice, howupsert_sqlmangles source-table names, how to add your ownOsmsubclass.docs/api.md— cheatsheet of every public export.
Prerequisites
osm2pgsql≥ 1.6 — install via package manager (sudo apt install osm2pgsqlon modern Ubuntu;brew install osm2pgsqlon macOS) or build from source.- PostGIS — 3.4+ recommended.
- The bundled pgosm-flex LUA config in
osmflex/management/flex-config/is sourced from rustprooflabs/pgosm-flex.
Development
uv sync --dev
uv run pytest # 24 tests
uv run ruff check .
uv run mypy osmflex
Releasing
Releases are automated via .github/workflows/release.yml using PyPI Trusted
Publishing (OIDC). To cut a release:
- Bump
versioninpyproject.tomlonmain; merge. - Tag the merged commit with the same version (no
vprefix):git tag 0.3.1 && git push origin 0.3.1
- The workflow verifies tag/pyproject match, builds sdist + wheel, publishes to PyPI, and creates a GitHub Release with generated notes.
Metadata
Release files for osmflex 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| osmflex-0.3.1.tar.gz | 92.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| osmflex-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 142.5 kB
Release files / osmflex-0.3.1.tar.gz
| Download URL | osmflex-0.3.1.tar.gz |
|---|---|
| Size | 92.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f85d6ee8a8f34b1d3c33753a3b6cddba50671c44a739b360f6489676c11e4b6d
|
|
BLAKE2b-256 checksum How to use checksums |
6b646856b673fd28bc72d9b0f9e308fd82314b6091894bfcb67cb8f03c8ae0d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 7, 2026.
Transparency logRelease files / osmflex-0.3.1-py3-none-any.whl
| Download URL | osmflex-0.3.1-py3-none-any.whl |
|---|---|
| Size | 49.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32eee5e996b412c07c61e0fe0f12ac9c1b6c8010751742ffe4e9b184dea5025d
|
|
BLAKE2b-256 checksum How to use checksums |
6f9c9328a221579c0c00d98667d12af08c5357c16a03ff148740c8d40e887c5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 7, 2026.
Transparency log