django-cities-light
django-cities-light copied to clipboard
cities_light command failure on alternate_name
Using postgres 15 and django 5.2 with psycopg2 with django_cities_light 3.10.2. The initial populating command python manage.py cities_light fails when attempting to populate alternative_names (everything else finished successfully):
...
INFO:cities_light:Downloading http://download.geonames.org/export/dump/alternateNames.zip into /home//.local/lib/python3.12/site-packages/cities_light/data/alternateNames.zip
INFO:cities_light:Extracting alternateNames.txt from /home//.local/lib/python3.12/site-packages/cities_light/data/alternateNames.zip into /home//.local/lib/python3.12/site-packages/cities_light/data/alternateNames.txt
INFO:cities_light:Forced import of alternateNames.zip because data do not seem to have installed successfully yet, note that this is equivalent to --force-import-all.
INFO:cities_light:Importing alternateNames.zip
INFO:cities_light:Importing parsed translation in the database
Traceback (most recent call last):
File "/home//app/backend/manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/home//.local/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home//.local/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home//.local/lib/python3.12/site-packages/django/core/management/base.py", line 416, in run_from_argv
self.execute(*args, **cmd_options)
File "/home//.local/lib/python3.12/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/cities_light/management/commands/cities_light.py", line 252, in handle
self.translation_import()
File "/home//.local/lib/python3.12/site-packages/cities_light/management/commands/cities_light.py", line 706, in translation_import
model.save(force_update=True)
File "/home//.local/lib/python3.12/site-packages/django/db/models/base.py", line 902, in save
self.save_base(
File "/home//.local/lib/python3.12/site-packages/django/db/models/base.py", line 1008, in save_base
updated = self._save_table(
^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/models/base.py", line 1138, in _save_table
updated = self._do_update(
^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/models/base.py", line 1203, in _do_update
return filtered._update(values) > 0
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/models/query.py", line 1286, in _update
return query.get_compiler(self.db).execute_sql(ROW_COUNT)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 2060, in execute_sql
row_count = super().execute_sql(result_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1623, in execute_sql
cursor.execute(sql, params)
File "/home//.local/lib/python3.12/site-packages/cacheops/transaction.py", line 98, in execute
result = self._no_monkey.execute(self, sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1816, in runner
return sentry_patched_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/sentry_sdk/integrations/django/__init__.py", line 652, in execute
result = real_execute(self, sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//.local/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home//.local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
django.db.utils.OperationalError: index row size 2848 exceeds btree version 4 maximum 2704 for index "cities_light_city_search_names_fb77fed2"
DETAIL: Index row references tuple (1314,1) in relation "cities_light_city".
HINT: Values larger than 1/3 of a buffer page cannot be indexed.
Consider a function index of an MD5 hash of the value, or use full text indexing.
Can yoou check the responses from this thread?
https://github.com/yourlabs/django-cities-light/issues/273
Thanks for pointing me to the thread! I don't want to stop indexing for performance reasons which is what it seems the workarounds do. But I did come up with another solution. Limiting the languages fixes the issue. In your django settings:
CITIES_LIGHT_TRANSLATION_LANGUAGES = ['en', 'abbr']
This will prevent whatever language is blocking the alternate name from populating in the db.