2010-03-27 04:14:53 +08:00
|
|
|
=============================
|
|
|
|
GeoDjango Management Commands
|
|
|
|
=============================
|
|
|
|
|
|
|
|
inspectdb
|
|
|
|
=========
|
|
|
|
|
2014-07-26 19:21:52 +08:00
|
|
|
.. describe:: django-admin inspectdb
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
When :mod:`django.contrib.gis` is in your :setting:`INSTALLED_APPS`, the
|
|
|
|
:djadmin:`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.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
ogrinspect
|
|
|
|
==========
|
2010-03-27 04:14:53 +08:00
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin:: ogrinspect data_source model_name
|
2010-03-27 04:14:53 +08:00
|
|
|
|
2014-03-03 00:05:57 +08:00
|
|
|
The ``ogrinspect`` management command will inspect the given OGR-compatible
|
2010-03-27 04:14:53 +08:00
|
|
|
:class:`~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`` :ref:`in the tutorial <ogrinspect-intro>`.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --blank BLANK
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --decimal DECIMAL
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
Use a comma separated list of OGR float fields to generate
|
|
|
|
:class:`~django.db.models.DecimalField` instead of the default
|
|
|
|
:class:`~django.db.models.FloatField`. Set to ``true`` to apply to all
|
|
|
|
OGR float fields.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --geom-name GEOM_NAME
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
Specifies the model attribute name to use for the geometry field.
|
|
|
|
Defaults to ``'geom'``.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --layer LAYER_KEY
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
The key for specifying which layer in the OGR
|
|
|
|
:class:`~django.contrib.gis.gdal.DataSource` source to use.
|
|
|
|
Defaults to 0 (the first layer). May be an integer or a string identifier
|
2013-04-16 00:26:25 +08:00
|
|
|
for the :class:`~django.contrib.gis.gdal.Layer`. When inspecting databases,
|
|
|
|
``layer`` is generally the table name you want to inspect.
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
.. django-admin-option:: --mapping
|
|
|
|
|
|
|
|
Automatically generate a mapping dictionary for use with
|
|
|
|
:class:`~django.contrib.gis.utils.LayerMapping`.
|
|
|
|
|
|
|
|
.. django-admin-option:: --multi-geom
|
|
|
|
|
|
|
|
When generating the geometry field, treat it as a geometry collection.
|
|
|
|
For example, if this setting is enabled then a
|
|
|
|
:class:`~django.contrib.gis.db.models.MultiPolygonField` will be placed
|
|
|
|
in the generated model rather than
|
|
|
|
:class:`~django.contrib.gis.db.models.PolygonField`.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --name-field NAME_FIELD
|
2010-03-27 04:14:53 +08:00
|
|
|
|
2014-02-09 19:38:13 +08:00
|
|
|
Generates a ``__str__`` routine (``__unicode__`` on Python 2) on the model
|
2013-11-06 17:47:07 +08:00
|
|
|
that will return the given field name.
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
.. django-admin-option:: --no-imports
|
|
|
|
|
|
|
|
Suppresses the ``from django.contrib.gis.db import models`` import statement.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --null NULL
|
2010-03-27 04:14:53 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
.. django-admin-option:: --srid SRID
|
2010-08-20 03:27:44 +08:00
|
|
|
|
2010-03-27 04:14:53 +08:00
|
|
|
The SRID to use for the geometry field. If not set, ``ogrinspect`` attempts
|
|
|
|
to automatically determine of the SRID of the data source.
|