new_contents: from __future__ import absolute_import, unicode_literals
  
  from django.core.management.base import BaseCommand
  from molo.core.models import PageTranslation, SiteLanguage, Page
  
  
  class Command(BaseCommand):
  
      def handle(self, *args, **options):
          # first add all the translations to the main language ArticlePage
          # and add the main language as a translated to the translated pages
          main_language = SiteLanguage.objects.get(is_main_language=True)
          pages = Page.objects.all().exclude(depth__in=[1, 2, 3, 4])
          for page in pages:
              if page.specific.language.pk == main_language.pk:
                  for translation in PageTranslation.objects.filter(page=page):
                      if translation.page and translation.translated_page:
                          page.specific.translated_pages.add(
                              translation.translated_page.specific)
                          translation.translated_page.specific.translated_pages\
                              .add(page.specific)
                          page.save()
                          translation.translated_page.save()
                      else:
                          self.stdout.write(self.style.NOTICE(
                              'Translation with pk "%s"'
                              'is missing page/translated_page'
                              % (translation.pk)))
  
          # loop through all translated_pages on the main language field and
          # add all the translations to the rest of the translated pages
          # except the language that it is in
          for page in Page.objects.all().exclude(depth__in=[1, 2, 3, 4]):
              print page.specific.translated_pages
              if page.specific.language.pk == main_language.pk:
                  for translated_page in page.specific.translated_pages.all():
                      translations = page.specific.translated_pages.all().\
                          exclude(language__pk=main_language.pk)
                      for translation in translations:
                          translated_page.translated_pages.add(translation)
                      translated_page.save()
  
subject: add script