Skip to content
Back to skills

Serialization

ASecurity

"Serialize GeoDjango geometries and model instances as

  • 247 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 8, 2026
developmentpythongobashdjangotestingapidatabasebackend

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill serialization --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Serialization?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Serialization
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-serialization-arex-skill/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-serialization-arex-skill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: serialization
description: "Serialize GeoDjango geometries and model instances as
  GeoJSON-compatible Geometry, Feature, or FeatureCollection data with validated
  input, IDs, properties, bboxes, precision, deduplication, transforms, and
  automatic field mapping."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Serialization

Use this skill when a DRF endpoint must read or write GeoJSON geometry values or
emit GeoJSON `Feature` / `FeatureCollection` objects. Start with
[references/api-reference.md](references/api-reference.md) for exact public
names, defaults, output shape, and validation messages. Use
[references/workflows.md](references/workflows.md) for complete serializer
recipes and [references/troubleshooting.md](references/troubleshooting.md) when
GeoDjango, geometry parsing, SRIDs, fields, or null/empty values fail.

## Route the request

- Use `GeometryField` for a model geometry field or a plain serializer geometry
  value. Configure `precision`, `remove_duplicates`, `auto_bbox`, and
  `transform` only when the representation needs them.
- Use `GeometrySerializerMethodField` when a serializer method computes the
  geometry. Return a `GEOSGeometry` or `None`.
- Use `GeoFeatureModelSerializer` for one GeoJSON `Feature`; pass `many=True`
  for a `FeatureCollection`. Set `Meta.geo_field` explicitly, including
  `None` for a geometry-less model, and choose `id_field`, properties, and bbox
  behavior deliberately.
- Use `get_properties()` and `unformat_geojson()` together when the GeoJSON
  `properties` object is not the model's ordinary serializer fields.
- Put query predicates in [spatial-filtering](../spatial-filtering/SKILL.md),
  pagination and OpenAPI behavior in
  [pagination-and-schema](../pagination-and-schema/SKILL.md), and database,
  native-test, and backend setup in
  [integration-testing](../integration-testing/SKILL.md).

## Operating sequence

1. Install `rest_framework_gis` after `rest_framework` in
   `INSTALLED_APPS` so its app config registers GeoDjango fields with DRF's
   `ModelSerializer` mapping. An explicitly declared `GeometryField` works
   without relying on automatic mapping.
2. For plain geometry input, accept a GeoJSON dictionary, WKT/EWKT/HEXEWKB
   string, or `GEOSGeometry`; send a JSON string when a multipart form cannot
   carry a nested dictionary.
3. For feature input, send `properties` plus optional `geometry`, `id`, and
   writable `bbox`. A partial update may omit `geometry`; DRF then retains the
   instance value.
4. Verify output as JSON-compatible data and test SRID transforms and spatial
   database behavior in the target environment. GEOS parsing alone does not
   prove ORM or PostGIS execution.

The deterministic, database-free smoke check is linked from
[references/workflows.md](references/workflows.md). From the runtime skill root,
run:

```bash
python sub-skills/serialization/scripts/geometry_smoke.py --help
python sub-skills/serialization/scripts/geometry_smoke.py
```

Files in this skill

  • SKILL.md3 KB
  • references/api-reference.md11.5 KB
  • references/troubleshooting.md12.1 KB
  • references/workflows.md10.7 KB
  • scripts/geometry_smoke.py3.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.