commands.txt 2.9 KB

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