docs: def create_and_update_from_json_data(d, user):
      """
      Create or update page based on python dict d loaded from JSON data.
      This applies all data except for redirect_to, which is done in a
      second pass after all pages have been imported,
  
      user is the User instance that will be used if the author can't
      be found in the DB.
  
      returns (page object, created, messages).
  
      created is True if this was a new page or False if an existing page
      was updated.
  
      messages is a list of strings warnings/messages about this import
      """
      page = None
      parent = None
      parent_required = True
      created = False
      messages = []
  
      page_languages = set(lang[0] for lang in settings.PAGE_LANGUAGES)
  
      for lang, s in list(d['complete_slug'].items()):
          if lang not in page_languages:
              messages.append(_("Language '%s' not imported") % (lang,))
              continue
  
          page = Page.objects.from_path(s, lang, exclude_drafts=False)
          if page and page.get_complete_slug(lang) == s:
              break
          if parent_required and parent is None:
              if '/' in s:
                  parent = Page.objects.from_path(s.rsplit('/', 1)[0], lang,
                      exclude_drafts=False)
              else:
                  parent_required = False
      else:
          # can't find an existing match, need to create a new Page
          page = Page(parent=parent)
          created = True
  
      user_model = get_user_model()
  
      def custom_get_user_by_email(email):
          """
          Simplified version
          """
          return user_model.objects.get(email=email)
  
      try:
          page.author = custom_get_user_by_email(d['author_email'])
      except (user_model.DoesNotExist, user_model.MultipleObjectsReturned):
          page.author = user
          messages.append(_("Original author '%s' not found")
              % (d['author_email'],))
  
      page.creation_date = datetime.strptime(d['creation_date'],
          ISODATE_FORMAT)
      page.publication_date = datetime.strptime(d['publication_date'],
          ISODATE_FORMAT) if d['publication_date'] else None
      page.publication_end_date = datetime.strptime(d['publication_end_date'],
          ISODATE_FORMAT) if d['publication_end_date'] else None
      page.last_modification_date = datetime.strptime(
          d['last_modification_date'], ISODATE_FORMAT)
      page.status = {
          'published': Page.PUBLISHED,
          'hidden': Page.HIDDEN,
          'draft': Page.DRAFT,
          }[d['status']]
      page.template = d['template']
      page.redirect_to_url = d['redirect_to_url']
  
      page.save()
  
      # Add tags
      if settings.PAGE_TAGGING:
          from taggit.models import Tag
          tags = d.get('tags', [])
          page.tags.clear()
          if tags:
              for tag in tags:
                  Tag.objects.get_or_create(name=tag)
                  page.tags.add(tag)
              page.save()
  
      if settings.PAGE_USE_SITE_ID:
          if d['sites']:
              for site in d['sites']:
                  try:
                      page.sites.add(Site.objects.get(domain=site))
                  except Site.DoesNotExist:
                      messages.append(_("Could not add site '%s' to page")
                          % (site,))
          if not settings.PAGE_HIDE_SITES and not page.sites.count():
              # need at least one site
              page.sites.add(Site.objects.get(pk=global_settings.SITE_ID))
  
      def create_content(lang, ctype, body):
          Content.objects.create_content_if_changed(page, lang, ctype, body)
  
      for lang in d['content_language_updated_order']:
          if lang not in page_languages:
              continue
          create_content(lang, 'slug',
              d['complete_slug'][lang].rsplit('/', 1)[-1])
          create_content(lang, 'title', d['title'][lang])
          for ctype, langs_bodies in list(d['content'].items()):
              create_content(lang, ctype, langs_bodies[lang])
  
      return page, created, messages