question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sync_translation_fields TypeError with Django 2.1.7

See original GitHub issue

I’m attempting to use Django 2.1.7 with wagtail 2.4, wagtail-modeltranslation 0.10.1 (django-modeltranslation>=0.13), and postgresql 9.6.12 and am running into the following error:

TypeError: sequence index must be integer, not 'slice'

Here’s a full stack trace:

/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/environ/environ.py:630: UserWarning: /home/travis/build/mozilla/foundation.mozilla.org/network-api/networkapi/.env doesn't exist - if you're not configuring your environment separately, create one.
  "environment separately, create one." % env_file)
Traceback (most recent call last):
  File "network-api/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
    super().run_from_argv(argv)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/commands/test.py", line 56, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/test/runner.py", line 604, in run_tests
    old_config = self.setup_databases()
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/test/runner.py", line 551, in setup_databases
    self.parallel, **kwargs
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/test/utils.py", line 174, in setup_databases
    serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/db/backends/base/creation.py", line 68, in create_test_db
    run_syncdb=True,
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
    return command.execute(*args, **defaults)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/wagtail_modeltranslation/management/commands/migrate_translation.py", line 33, in handle
    sync_page_command.handle(*args, **options)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/wagtail_modeltranslation/management/commands/sync_page_translation_fields.py", line 26, in handle
    super(Command, self).handle(*args, **options)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/modeltranslation/management/commands/sync_translation_fields.py", line 83, in handle
    missing_langs = list(self.get_missing_languages(column_name, db_table))
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/modeltranslation/management/commands/sync_translation_fields.py", line 112, in get_missing_languages
    db_table_fields = self.get_table_fields(db_table)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/modeltranslation/management/commands/sync_translation_fields.py", line 105, in get_table_fields
    db_table_desc = self.introspection.get_table_description(self.cursor, db_table)
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/db/backends/postgresql/introspection.py", line 69, in get_table_description
    for line in cursor.description
  File "/home/travis/virtualenv/python3.6.8/lib/python3.6/site-packages/django/db/backends/postgresql/introspection.py", line 69, in <listcomp>
    for line in cursor.description
TypeError: sequence index must be integer, not 'slice'

I dug into django/db/backends/postgresql/introspection.py and found that the method that the management command sync_translation_fields calls (get_table_description) fails in Django 2.1 possibly due to this change in introspection.py about a year ago

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

4reactions
last-partizancommented, Apr 17, 2019

@Pomax

Bad news: looks like this bug has nothing to do with django-modeltranslation. Good news: you can fix it by installing psycopg2-binary<2.8

1reaction
Pomaxcommented, Apr 17, 2019

That’s awesome, thanks so much for discovering that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django 2.1.3 Error: __init__() takes 1 positional argument but ...
I am trying to develop a website with Django 2.1.3 and python 3.7.1 When I go to the homepage I get this error:...
Read more >
Django Deprecation Timeline
This document outlines when various pieces of Django will be removed or altered in a backward incompatible way, following their deprecation, ...
Read more >
Django 4.0 release notes
Unsupported operations on a sliced queryset now raise TypeError instead of AssertionError . The undocumented django.test.runner.reorder_suite() ...
Read more >
Django 3.2 release notes
Instantiating an abstract model now raises TypeError . Keyword arguments to setup_databases() are now keyword-only.
Read more >
Release notes - Django documentation
Release notes for the official Django releases. Each release note will tell you what's new in each version, and will also describe any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found