Skip to main content

CI PyPI

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, how upsert_sql mangles source-table names, how to add your own Osm subclass.
  • docs/api.md — cheatsheet of every public export.

Prerequisites

  • osm2pgsql ≥ 1.6 — install via package manager (sudo apt install osm2pgsql on modern Ubuntu; brew install osm2pgsql on 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:

  1. Bump version in pyproject.toml on main; merge.
  2. Tag the merged commit with the same version (no v prefix):
    git tag 0.3.1 && git push origin 0.3.1
    
  3. The workflow verifies tag/pyproject match, builds sdist + wheel, publishes to PyPI, and creates a GitHub Release with generated notes.

Download files

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

Source Distribution

osmflex-0.3.1.tar.gz (92.9 kB view details)

Uploaded Source

Built Distribution

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

osmflex-0.3.1-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

Details for the file osmflex-0.3.1.tar.gz.

File metadata

  • Download URL: osmflex-0.3.1.tar.gz
  • Upload date:
  • Size: 92.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for osmflex-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f85d6ee8a8f34b1d3c33753a3b6cddba50671c44a739b360f6489676c11e4b6d
MD5 f12fdc20b44eb8cf961be99253711a93
BLAKE2b-256 6b646856b673fd28bc72d9b0f9e308fd82314b6091894bfcb67cb8f03c8ae0d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmflex-0.3.1.tar.gz:

Publisher: release.yml on catalpainternational/osm2django

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osmflex-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: osmflex-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 49.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for osmflex-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32eee5e996b412c07c61e0fe0f12ac9c1b6c8010751742ffe4e9b184dea5025d
MD5 69601f94432865ef71b92aecae9a3001
BLAKE2b-256 6f9c9328a221579c0c00d98667d12af08c5357c16a03ff148740c8d40e887c5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for osmflex-0.3.1-py3-none-any.whl:

Publisher: release.yml on catalpainternational/osm2django

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

Supported by

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