Skip to content

Commit 0fa6655

Browse files
authored
Fix translating a page - MultipleObjectsReturned (#1605)
1 parent 726b718 commit 0fa6655

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.core.management import BaseCommand
2+
from wagtail.core.models import Page
3+
from wagtail_localize.models import TranslationSource
4+
5+
6+
class Command(BaseCommand):
7+
def handle(self, *args, **options):
8+
for page in Page.objects.all():
9+
translation_sources = TranslationSource.objects.filter(
10+
object_id=page.translation_key,
11+
specific_content_type=page.content_type_id,
12+
translations__target_locale=page.locale,
13+
)
14+
15+
if translation_sources.count() > 1:
16+
self.stdout.write(f"Multiple translation sources found for page: {page.id}, title: {page.title}")
17+
for translation_source in translation_sources:
18+
self.stdout.write(f" - Translation source: {translation_source.id}, locale: {translation_source.locale}")

iogt/settings/base.py

+5
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,8 @@
566566

567567
# Width size options are 360, 750
568568
IMAGE_SIZE_PRESET = int(os.getenv('IMAGE_SIZE_PRESET', '') or '360')
569+
570+
# Default primary key field type introduced in Django 3.2 or later versions
571+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
572+
573+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ django-debug-toolbar==3.2.1
66
django-extensions==3.1.*
77
django-sass-processor==1.0.*
88
django-translation-manager~=1.3.0
9-
django==3.1.*
9+
django==3.2.*
1010
elasticsearch~=7.16
1111
libsass==0.21.*
1212
lxml==4.8.*
1313
psycopg2==2.8.*
1414
redis~=3.0
1515
tqdm==4.62.*
16-
wagtail-localize==1.2.1
16+
wagtail-localize==1.3.3
1717
wagtail-markdown==0.7.0
1818
Markdown==3.3.7
1919
wagtail==2.15.*

0 commit comments

Comments
 (0)