wagtail / guide

A website to teach Wagtail CMS to content editors, moderators and administrators.
https://guide.wagtail.org
BSD 3-Clause "New" or "Revised" License
32 stars 26 forks source link

Portuguese (Brazil) References page: runtime error #317

Open thibaudcolas opened 1 year ago

thibaudcolas commented 1 year ago

On trying to access the editing UI: https://guide.wagtail.org/admin/pages/504/edit/

Server error:

wagtail_localize.models.Translation.MultipleObjectsReturned: get() returned more than one Translation -- it returned 2!

Stack trace – looks like the issue is in one of the localize hooks before_edit_page:

Internal Server Error: /admin/pages/504/edit/
Traceback (most recent call last):
  File "django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "wagtail/admin/urls/__init__.py", line 165, in wrapper
    return view_func(request, *args, **kwargs)
  File "wagtail/admin/auth.py", line 182, in decorated_view
    response = view_func(request, *args, **kwargs)
  File "django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "wagtail/admin/views/pages/edit.py", line 347, in dispatch
    response = self.run_hook("before_edit_page", self.request, self.page)
  File "wagtail/admin/views/generic/mixins.py", line 27, in run_hook
    result = fn(*args, **kwargs)
  File "wagtail_localize/wagtail_hooks.py", line 274, in before_edit_page
    translation = Translation.objects.get(
  File "django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 653, in get
    raise self.model.MultipleObjectsReturned(

I had to work around this to get this section of the site publish in Portuguese (Brazil), so have deleted the page and made https://guide.wagtail.org/admin/pages/547/edit/ instead.