---
title: "GeoDjango Management Commands"
version: 4.2
locale: ja
source: https://docs.djangoproject.com/ja/4.2/ref/contrib/gis/commands/
canonical: https://djangodocs.dev/ja/4.2/ref/contrib/gis/commands/
---
# GeoDjango Management Commands

## `inspectdb`

#### `django-admin inspectdb`

When [`django.contrib.gis`](/ja/4.2/ref/contrib/gis/#module-django.contrib.gis) is in your [`INSTALLED_APPS`](/ja/4.2/ref/settings/#std-setting-INSTALLED_APPS), the
[`inspectdb`](/ja/4.2/ref/django-admin/#django-admin-inspectdb) management command is overridden with one from GeoDjango.
The overridden command is spatially-aware, and places geometry fields in the
auto-generated model definition, where appropriate.

## `ogrinspect`

#### `django-admin ogrinspect data_source model_name`

The `ogrinspect` management command will inspect the given OGR-compatible
[`DataSource`](/ja/4.2/ref/contrib/gis/gdal/#django.contrib.gis.gdal.DataSource) (e.g., a shapefile) and will
output a GeoDjango model with the given model name.  There's a detailed example
of using `ogrinspect` [in the tutorial](/ja/4.2/ref/contrib/gis/tutorial/#ogrinspect-intro).

#### `--blank BLANK`

Use a comma separated list of OGR field names to add the `blank=True`
keyword option to the field definition.  Set with `true` to apply
to all applicable fields.

#### `--decimal DECIMAL`

Use a comma separated list of OGR float fields to generate
[`DecimalField`](/ja/4.2/ref/models/fields/#django.db.models.DecimalField) instead of the default
[`FloatField`](/ja/4.2/ref/models/fields/#django.db.models.FloatField). Set to `true` to apply to all
OGR float fields.

#### `--geom-name GEOM_NAME`

Specifies the model attribute name to use for the geometry field.
Defaults to `'geom'`.

#### `--layer LAYER_KEY`

The key for specifying which layer in the OGR
[`DataSource`](/ja/4.2/ref/contrib/gis/gdal/#django.contrib.gis.gdal.DataSource) source to use.
Defaults to 0 (the first layer). May be an integer or a string identifier
for the [`Layer`](/ja/4.2/ref/contrib/gis/gdal/#django.contrib.gis.gdal.Layer). When inspecting databases,
`layer` is generally the table name you want to inspect.

#### `--mapping`

Automatically generate a mapping dictionary for use with
[`LayerMapping`](/ja/4.2/ref/contrib/gis/layermapping/#django.contrib.gis.utils.LayerMapping).

#### `--multi-geom`

When generating the geometry field, treat it as a geometry collection.
For example, if this setting is enabled then a
[`MultiPolygonField`](/ja/4.2/ref/contrib/gis/model-api/#django.contrib.gis.db.models.MultiPolygonField) will be placed
in the generated model rather than
[`PolygonField`](/ja/4.2/ref/contrib/gis/model-api/#django.contrib.gis.db.models.PolygonField).

#### `--name-field NAME_FIELD`

Generates a `__str__()` method on the model that returns the given field
name.

#### `--no-imports`

Suppresses the `from django.contrib.gis.db import models` import statement.

#### `--null NULL`

Use a comma separated list of OGR field names to add the `null=True`
keyword option to the field definition.  Set with `true` to apply to
all applicable fields.

#### `--srid SRID`

The SRID to use for the geometry field.  If not set, `ogrinspect` attempts
to automatically determine of the SRID of the data source.
