| 1 |
from django.core.management.commands.inspectdb import Command as InspectDBCommand |
| 2 |
|
| 3 |
|
| 4 |
class Command(InspectDBCommand): |
| 5 |
db_module = "django.contrib.gis.db" |
| 6 |
|
| 7 |
def get_field_type(self, connection, table_name, row): |
| 8 |
field_type, field_params, field_notes = super().get_field_type( |
| 9 |
connection, table_name, row |
| 10 |
) |
| 11 |
if field_type == "GeometryField": |
| 12 |
# Getting a more specific field type and any additional parameters |
| 13 |
# from the `get_geometry_type` routine for the spatial backend. |
| 14 |
field_type, geo_params = connection.introspection.get_geometry_type( |
| 15 |
table_name, row |
| 16 |
) |
| 17 |
field_params.update(geo_params) |
| 18 |
return field_type, field_params, field_notes |