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
| Attribute | Type | Description |
|---|---|---|
| help | string = "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_checks | list = [] | 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
| Name | Type | Description |
|---|---|---|
| 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
| Type | Description |
|---|---|
null | Nothing 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
| Name | Type | Description |
|---|---|---|
| *args | tuple | Variable positional arguments passed to the command. |
| **options | dict | Parsed command line arguments including 'data_source', 'model_name', and formatting flags like 'srid' or 'mapping'. |
Returns
| Type | Description |
|---|---|
string | A multi-line string containing the auto-generated Django model code and mapping dictionary. |