commands.txt 3.0 KB

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