inspectdb¶当 django.contrib.gis 在您的 INSTALLED_APPS 中时,管理命令 inspectdb 会被 GeoDjango 中的命令所覆盖。覆盖后的命令具有空间感知功能,并在适当的情况下将几何字段放在自动生成的模型定义中。
ogrinspect¶The ogrinspect management command will inspect the given OGR-compatible
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.
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.
使用逗号分隔的 OGR 浮点字段列表来生成 DecimalField,而不是默认的 FloatField。设置为 true,以应用于所有 OGR 浮点字段。
指定要用于几何字段的模型属性名称。默认为 'geom'。
用于指定在 OGR DataSource 源中要使用的图层的键。默认为 0(第一个图层)。可以是整数或 Layer 的字符串标识符。在检查数据库时,通常 layer 是您要检查的表名。
自动生成一个映射字典,用于与 LayerMapping 配合使用。
在生成几何字段时,将其视为几何集合。例如,如果启用了此设置,则生成的模型中将放置一个 MultiPolygonField,而不是 PolygonField。
在模型上生成一个返回指定字段名称的 __str__() 方法。
抑制了 from django.contrib.gis.db import models 的导入语句。
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.
The SRID to use for the geometry field. If not set, ogrinspect attempts
to automatically determine of the SRID of the data source.
12月 22, 2025