Portuguese (Brazil) References page: runtime error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 36
- Forks
- 39
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in wagtail_localize/wagtail_hooks.py at before_edit_page and inspect the Translation.objects.get call shown in the traceback. Reproduce the Portuguese (Brazil) References page edit flow, using the replacement page 547 if needed; done means the editing UI no longer raises MultipleObjectsReturned and the translation can be edited normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100