wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

no such table: wagtail_localize_translatableobject #232

Open kaphadley opened 4 years ago

kaphadley commented 4 years ago

I followed the Wagtail's documentation to enable multi-language support:
https://docs.wagtail.io/en/stable/advanced_topics/i18n.html#multi-language-content

Then I installed wagtail-localize by following the readme instructions.

When I open a page in the admin, I get an error:
no such table: wagtail_localize_translatableobject

Traceback ``` Environment: Request Method: GET Request URL: http://localhost:8000/admin/pages/3/ Django Version: 3.1.3 Python Version: 3.8.6 Installed Applications: ['home', 'search', 'wagtail.contrib.forms', 'wagtail.contrib.redirects', 'wagtail.embeds', 'wagtail.sites', 'wagtail.users', 'wagtail.snippets', 'wagtail.documents', 'wagtail.images', 'wagtail.search', 'wagtail.admin', 'wagtail.core', 'wagtail_localize', 'wagtail_localize.locales', 'modelcluster', 'taggit', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.locale.LocaleMiddleware', 'wagtail.contrib.redirects.middleware.RedirectMiddleware'] Template error: In template /usr/local/lib/python3.8/site-packages/wagtail/admin/templates/wagtailadmin/pages/listing/_buttons.html, error at line 2 no such table: wagtail_localize_translatableobject 1 : {% for button in buttons %} 2 : {% if button.show %} 3 :
  • {{ button|safe }}
  • 4 : {% endif %} 5 : {% endfor %} 6 : Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] During handling of the above exception ('ButtonWithDropdownFromHook' object is not subscriptable), another exception occurred: File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute return Database.Cursor.execute(self, query, params) The above exception (no such table: wagtail_localize_translatableobject) was the direct cause of the following exception: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response response = response.render() File "/usr/local/lib/python3.8/site-packages/wagtail/admin/auth.py", line 187, in overridden_render return render() File "/usr/local/lib/python3.8/site-packages/django/template/response.py", line 105, in render self.content = self.rendered_content File "/usr/local/lib/python3.8/site-packages/django/template/response.py", line 83, in rendered_content return template.render(context, self._request) File "/usr/local/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 170, in render return self._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 192, in render return template.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 172, in render return self._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 312, in render return nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 192, in render return template.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 172, in render return self._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/library.py", line 234, in render return t.render(new_context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 172, in render return self._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 211, in render nodelist.append(node.render_annotated(context)) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 305, in render match = condition.eval(context) File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 889, in eval return self.value.resolve(context, ignore_failures=True) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 671, in resolve obj = self.var.resolve(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 796, in resolve value = self._resolve_lookup(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 837, in _resolve_lookup current = getattr(current, bit) File "/usr/local/lib/python3.8/site-packages/wagtail/admin/widgets/button.py", line 94, in show return bool(self.dropdown_buttons) File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python3.8/site-packages/wagtail/admin/widgets/button.py", line 103, in dropdown_buttons buttons.extend(hook(self.page, self.page_perms, self.is_parent, self.next_url)) File "/usr/local/lib/python3.8/site-packages/wagtail_localize/wagtail_hooks.py", line 77, in page_listing_more_buttons source = TranslationSource.objects.get_for_instance_or_none(page) File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/wagtail_localize/models.py", line 141, in get_for_instance_or_none return self.get_for_instance(instance) File "/usr/local/lib/python3.8/site-packages/wagtail_localize/models.py", line 131, in get_for_instance object = TranslatableObject.objects.get_for_instance( File "/usr/local/lib/python3.8/site-packages/wagtail_localize/models.py", line 60, in get_for_instance return self.get( File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 425, in get num = len(clone) File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 269, in __len__ self._fetch_all() File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1308, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 53, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute return Database.Cursor.execute(self, query, params) Exception Type: OperationalError at /admin/pages/3/ Exception Value: no such table: wagtail_localize_translatableobject ``` And the public side doesn't work either: **Error during template rendering** ``` Environment: Request Method: GET Request URL: http://localhost:8000/ Django Version: 3.1.3 Python Version: 3.8.6 Installed Applications: ['home', 'search', 'wagtail.contrib.forms', 'wagtail.contrib.redirects', 'wagtail.embeds', 'wagtail.sites', 'wagtail.users', 'wagtail.snippets', 'wagtail.documents', 'wagtail.images', 'wagtail.search', 'wagtail.admin', 'wagtail.core', 'wagtail_localize', 'wagtail_localize.locales', 'modelcluster', 'taggit', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.locale.LocaleMiddleware', 'wagtail.contrib.redirects.middleware.RedirectMiddleware'] Template error: In template /app/coha/templates/base.html, error at line 39 de 29 : 30 : 31 : {% wagtailuserbar %} 32 :
    33 :

    HaL

    34 : 35 : {% for language_code, language_name in LANGUAGES %} 36 : {% get_language_info for language_code as lang %} 37 : 38 : {% language language_code %} 39 : 40 : {{ lang.name_local }} 41 : 42 : {% endlanguage %} 43 : {% endfor %} 44 :
    45 : 46 :
    47 : {% block content %}{% endblock %} 48 :
    49 : Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] During handling of the above exception ('HomePage' object is not subscriptable), another exception occurred: File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response response = response.render() File "/usr/local/lib/python3.8/site-packages/django/template/response.py", line 105, in render self.content = self.rendered_content File "/usr/local/lib/python3.8/site-packages/django/template/response.py", line 83, in rendered_content return template.render(context, self._request) File "/usr/local/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 170, in render return self._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 211, in render nodelist.append(node.render_annotated(context)) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/templatetags/i18n.py", line 187, in render output = self.nodelist.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/usr/local/lib/python3.8/site-packages/django/template/library.py", line 191, in render resolved_args, resolved_kwargs = self.get_resolved_arguments(context) File "/usr/local/lib/python3.8/site-packages/django/template/library.py", line 177, in get_resolved_arguments resolved_args = [var.resolve(context) for var in self.args] File "/usr/local/lib/python3.8/site-packages/django/template/library.py", line 177, in resolved_args = [var.resolve(context) for var in self.args] File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 671, in resolve obj = self.var.resolve(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 796, in resolve value = self._resolve_lookup(context) File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 837, in _resolve_lookup current = getattr(current, bit) File "/usr/local/lib/python3.8/site-packages/wagtail/core/models.py", line 1229, in localized localized = self.localized_draft File "/usr/local/lib/python3.8/site-packages/wagtail/core/models.py", line 1212, in localized_draft locale = Locale.get_active() File "/usr/local/lib/python3.8/site-packages/wagtail/core/models.py", line 372, in get_active return cls.objects.get_for_language(translation.get_language()) File "/usr/local/lib/python3.8/site-packages/wagtail/core/models.py", line 339, in get_for_language return self.get(language_code=get_supported_content_language_variant(language_code)) File "/usr/local/lib/python3.8/site-packages/wagtail/core/utils.py", line 271, in get_supported_content_language_variant raise LookupError(lang_code) Exception Type: LookupError at / Exception Value: de ```

    Any idea on what is wrong?

    kaedroho commented 4 years ago

    Did you run python manage.py migrate after installing wagtail-localize? Also, have you added at least one variant of de into WAGTAIL_CONTENT_LANGUAGES?

    kaphadley commented 4 years ago

    Thank you for your answer, I did not run any migration. I am new to wagtail and I simply followed the wagtail's instruction then the readme of wagtail-localize. The only reference to a migration that I saw was related to snippets.

    I would suggest:

    Now the dashboard and the homepage work! I translated the homepage, in the dashboard and it also works. But I am still unable to access the translated page.

    The link to the translation points to /None:

        {% for language_code, language_name in LANGUAGES %}
          {% get_language_info for language_code as lang %}
    
          {% language language_code %}
          <a href="{% pageurl page.localized %}" rel="alternate" hreflang="{{ language_code }}">
            {{ lang.name_local }}
          </a>
          {% endlanguage %}
        {% endfor %}

    I neither can access the page by /translated-slug nor /de/tranlated-slug nor any other combination that I tried (404).

    Another question: wagtail-localize philosophy is to write in the default language and to translate right? There is no way to create the initial content in another language and then translate to the site's default (or to never translate it)?