Skip to main content

Command

This class inspects an OGR-compatible data source and generates a GeoDjango model definition based on its structure. It provides extensive options for customizing field types, handling null or blank values, and specifying spatial reference identifiers. Additionally, the class can generate a mapping dictionary for use with data import utilities.

Attributes

AttributeTypeDescription
helpstring = "Inspects the given OGR-compatible data source (e.g., a shapefile) and outputs\na GeoDjango model with the given model name. For example:\n ./manage.py ogrinspect zipcode.shp Zipcode"Inspects the given OGR-compatible data source (e.g., a shapefile) and outputs
a GeoDjango model with the given model name. For example:
./manage.py ogrinspect zipcode.shp Zipcode
requires_system_checkslist = []A list of system checks that must be performed before the command is executed, which is empty for this command.

Methods


add_arguments()

@classmethod
def add_arguments(
parser: [CommandParser](../../../../../core/management/base/commandparser.md?sid=django_core_management_base_commandparser)
) - > null

Configures the command line argument parser with options for data source inspection and model generation.

Parameters

NameTypeDescription
parser[CommandParser](../../../../../core/management/base/commandparser.md?sid=django_core_management_base_commandparser)The argument parser instance to which OGR inspection options and flags will be added.

Returns

TypeDescription
nullNothing is returned; the parser object is modified in place.

handle()

@classmethod
def handle(
*args: tuple,
**options: dict
) - > string

Inspects the specified OGR-compatible data source and generates the string representation of a GeoDjango model and optional LayerMapping dictionary.

Parameters

NameTypeDescription
*argstupleVariable positional arguments passed to the command.
**optionsdictParsed command line arguments including 'data_source', 'model_name', and formatting flags like 'srid' or 'mapping'.

Returns

TypeDescription
stringA multi-line string containing the auto-generated Django model code and mapping dictionary.