| 1 |
============================= |
| 2 |
GeoDjango Management Commands |
| 3 |
============================= |
| 4 |
|
| 5 |
``inspectdb`` |
| 6 |
============= |
| 7 |
|
| 8 |
.. describe:: django-admin inspectdb |
| 9 |
|
| 10 |
When :mod:`django.contrib.gis` is in your :setting:`INSTALLED_APPS`, the |
| 11 |
:djadmin:`inspectdb` management command is overridden with one from GeoDjango. |
| 12 |
The overridden command is spatially-aware, and places geometry fields in the |
| 13 |
auto-generated model definition, where appropriate. |
| 14 |
|
| 15 |
``ogrinspect`` |
| 16 |
============== |
| 17 |
|
| 18 |
.. django-admin:: ogrinspect data_source model_name |
| 19 |
|
| 20 |
The ``ogrinspect`` management command will inspect the given OGR-compatible |
| 21 |
:class:`~django.contrib.gis.gdal.DataSource` (e.g., a shapefile) and will |
| 22 |
output a GeoDjango model with the given model name. There's a detailed example |
| 23 |
of using ``ogrinspect`` :ref:`in the tutorial <ogrinspect-intro>`. |
| 24 |
|
| 25 |
.. django-admin-option:: --blank BLANK |
| 26 |
|
| 27 |
Use a comma separated list of OGR field names to add the ``blank=True`` |
| 28 |
keyword option to the field definition. Set with ``true`` to apply |
| 29 |
to all applicable fields. |
| 30 |
|
| 31 |
.. django-admin-option:: --decimal DECIMAL |
| 32 |
|
| 33 |
Use a comma separated list of OGR float fields to generate |
| 34 |
:class:`~django.db.models.DecimalField` instead of the default |
| 35 |
:class:`~django.db.models.FloatField`. Set to ``true`` to apply to all |
| 36 |
OGR float fields. |
| 37 |
|
| 38 |
.. django-admin-option:: --geom-name GEOM_NAME |
| 39 |
|
| 40 |
Specifies the model attribute name to use for the geometry field. |
| 41 |
Defaults to ``'geom'``. |
| 42 |
|
| 43 |
.. django-admin-option:: --layer LAYER_KEY |
| 44 |
|
| 45 |
The key for specifying which layer in the OGR |
| 46 |
:class:`~django.contrib.gis.gdal.DataSource` source to use. |
| 47 |
Defaults to 0 (the first layer). May be an integer or a string identifier |
| 48 |
for the :class:`~django.contrib.gis.gdal.Layer`. When inspecting databases, |
| 49 |
``layer`` is generally the table name you want to inspect. |
| 50 |
|
| 51 |
.. django-admin-option:: --mapping |
| 52 |
|
| 53 |
Automatically generate a mapping dictionary for use with |
| 54 |
:class:`~django.contrib.gis.utils.LayerMapping`. |
| 55 |
|
| 56 |
.. django-admin-option:: --multi-geom |
| 57 |
|
| 58 |
When generating the geometry field, treat it as a geometry collection. |
| 59 |
For example, if this setting is enabled then a |
| 60 |
:class:`~django.contrib.gis.db.models.MultiPolygonField` will be placed |
| 61 |
in the generated model rather than |
| 62 |
:class:`~django.contrib.gis.db.models.PolygonField`. |
| 63 |
|
| 64 |
.. django-admin-option:: --name-field NAME_FIELD |
| 65 |
|
| 66 |
Generates a ``__str__()`` method on the model that returns the given field |
| 67 |
name. |
| 68 |
|
| 69 |
.. django-admin-option:: --no-imports |
| 70 |
|
| 71 |
Suppresses the ``from django.contrib.gis.db import models`` import statement. |
| 72 |
|
| 73 |
.. django-admin-option:: --null NULL |
| 74 |
|
| 75 |
Use a comma separated list of OGR field names to add the ``null=True`` |
| 76 |
keyword option to the field definition. Set with ``true`` to apply to |
| 77 |
all applicable fields. |
| 78 |
|
| 79 |
.. django-admin-option:: --srid SRID |
| 80 |
|
| 81 |
The SRID to use for the geometry field. If not set, ``ogrinspect`` attempts |
| 82 |
to automatically determine of the SRID of the data source. |