django-extensions / django-extensions

This is a repository for collecting global custom management extensions for the Django Framework.
https://django-extensions.readthedocs.io
MIT License
6.58k stars 1.16k forks source link

Cannot use when GIS Polygon Columns are present #1850

Open FilippoPagano opened 1 year ago

FilippoPagano commented 1 year ago

When I run python manage.py sqldiff app I get AttributeError: 'str' object has no attribute 'name' because I have PostGIS Polygon columns in my postgres database.

This one might be a bug in django GIS, but I'm not sure. (File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\contrib\gis\db\backends\postgis\introspection.py", line 51, in get_geometry_type (table_name, description.name))

Complete stack trace: PS C:\Users\USER\workspace\urbanfarmer\django-urban-farmer> python manage.py sqldiff app Traceback (most recent call last): File "C:\Users\USER\workspace\urbanfarmer\django-urban-farmer\manage.py", line 19, in <module> main() File "C:\Users\USER\workspace\urbanfarmer\django-urban-farmer\manage.py", line 16, in main execute_from_command_line(sys.argv) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line utility.execute() File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\core\management\__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 1402, in run_from_argv super().run_from_argv(argv) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\core\management\base.py", line 412, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 1389, in execute super().execute(*args, **options) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\core\management\base.py", line 458, in execute output = self.handle(*args, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\utils.py", line 62, in inner ret = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 1382, in handle sqldiff_instance.find_differences() File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 694, in find_differences self.find_field_type_differ(meta, table_description, table_name) File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 568, in find_field_type_differ db_type = self.get_field_db_type(description, field, table_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 1204, in get_field_db_type db_type = super().get_field_db_type(description, field, table_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django_extensions\management\commands\sqldiff.py", line 343, in get_field_db_type reverse_type, geo_params = self.introspection.get_geometry_type(table_name, geo_col) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\USER\AppData\Roaming\Python\Python311\site-packages\django\contrib\gis\db\backends\postgis\introspection.py", line 51, in get_geometry_type (table_name, description.name), ^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'name'

julopezc-acciona commented 2 months ago

~Check out https://github.com/django-extensions/django-extensions/pull/1883 and see if it solves the issue~ https://github.com/django-extensions/django-extensions/pull/1860 is a better solution

FilippoPagano commented 2 months ago

Duplicate of #1652