DjangoGeoExporter
DjangoGeoExporter provides declarative flat, relational, and geospatial exports from Django querysets.
Quickstart
Install the package with the features required by your project:
poetry add "djangogeoexporter[all]"
Available extras are spreadsheet (XLSX and ODS), parquet, gpkg
(GeoPackage), and all. With pip, use the equivalent command:
pip install "djangogeoexporter[all]"
Declare an export using your Django models:
from djangogeoexporter import ExportDefinition, ExportTable, Field, JSONField
from myapp.models import Commune, Observation
class ObservationsExport(ExportDefinition):
name = "observations"
tables = (
ExportTable(
"communes",
Commune.objects.all(),
("id", "name", "geom"),
geometry_field="geom",
crs="EPSG:4326",
),
ExportTable(
"observations",
Observation.objects.select_related("commune"),
(
"id",
Field("commune", source="commune__name"),
"observed_at",
),
),
)
Generate the export and dispose of its temporary file when finished:
from shutil import copyfile
from djangogeoexporter import export
result = export(ObservationsExport, format="gpkg")
try:
copyfile(result.path, result.filename)
finally:
result.cleanup()
Supported formats include CSV, TSV, XLSX, ODS, Parquet/GeoParquet, and GeoPackage. Relational CSV and TSV exports are returned as ZIP archives.
JSON and JSONB fields
Django models.JSONField columns (backed by json or jsonb in PostgreSQL)
are detected automatically. Their values are stored as strict, compact UTF-8
JSON text in every output format. This avoids format-dependent structures and
allows the exported value to be consumed directly with json.loads(value) in
Python or cast with value::jsonb in PostgreSQL. In particular, JSON null is
exported as null, while a regular nullable field keeps the format's normal
empty/null representation.
For a plain iterable, a computed field, or an annotation that cannot be identified through Django model metadata, mark the field explicitly:
ExportTable(
"observations",
rows,
("id", JSONField("metadata")),
)
Only standard JSON values are accepted. Non-standard floating-point values
such as NaN and Infinity are rejected because PostgreSQL cannot import
them as JSON/JSONB.
See the docs/ directory for configuration, dynamic export contexts,
field labels, Django response integration, and format-specific options.
Code quality
Install development dependencies with poetry install --with dev. Ruff handles
linting, import sorting, and formatting, using a line length of 79 characters.
To test all export formats, install the optional dependencies as well:
poetry install --with test -E all
poetry run pytest
Without the extras, tests requiring optional export dependencies are skipped.
Django integration tests also require a running PostgreSQL/PostGIS database
configured through config.settings_test.
make lint: run lint checks.make format: sort imports and format Python code.make check: check linting and formatting without modifying files.
Run poetry run pre-commit install to enable the Ruff hooks before commits.
For VS Code, install the Ruff extension (charliermarsh.ruff).
Releases (GitLab / PyPI)
Tags in the exact format x.x.x (for example 0.1.0, without a v
prefix) trigger package publication after the unit and integration tests pass.
The pipeline builds a wheel and source distribution, validates their metadata,
publishes both to PyPI, then creates a GitLab release. Build artifacts include
the packages and extracted release notes.
Before the first publication, configure PYPI_API_TOKEN in GitLab under
Settings > CI/CD > Variables with a PyPI API token authorized to publish
djangogeoexporter. Mark the variable as masked and protected, and protect
release tags under Settings > Repository > Protected tags so those pipelines
can access it. For a new PyPI project, the first upload requires an account
token; once the project exists, use a project-scoped token.
Before tagging, add a unique, non-empty section to CHANGELOG.md:
## [0.1.0] - 2026-11-10
### Changes
- Describe the changes included in this release.
Commit the changelog, then create and push the tag:
git tag 0.1.0
git push origin 0.1.0
The tag sets the package version during the build; no version commit is created. Missing, empty or duplicate changelog sections stop publication. PyPI versions cannot be overwritten: publish subsequent changes with a new version tag.
Metadata
Release files for djangogeoexporter 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 |
|---|---|---|---|---|
| djangogeoexporter-0.1.0.tar.gz | 24.7 kB | Without provenance | Details for djangogeoexporter-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djangogeoexporter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for djangogeoexporter-0.1.0-py3-none-any.whl |
Total release size: 49.6 kB
Release files / djangogeoexporter-0.1.0.tar.gz
| Download URL | djangogeoexporter-0.1.0.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d4e71974e97b16cdfc9d311010cbdd86d1943d4e72ec8769c46c702836ec5b4
|
|
BLAKE2b-256 checksum How to use checksums |
a4ac3d9dee8bda5e289a9593d4ea5ee94840edfe556a2badc1c13b7215709178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / djangogeoexporter-0.1.0-py3-none-any.whl
| Download URL | djangogeoexporter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5465c436e24d5f779075381b69409629c4c33d9626b4a715d4704aa573a9faaa
|
|
BLAKE2b-256 checksum How to use checksums |
ce1891692d588e5fc9da0ff96240919262fe6362781934fcc1b8efa1f2eaf17b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for djangogeoexporter 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.