# Generated by Django 2.2.24 on 2024-09-26 11:53 from django.conf import settings from django.db import migrations from django.template import Context, Template from django.utils import translation from ishtar_common.utils_migrations import HOMEPAGE_DEFAULT, HOMEPAGE_TITLE def default_welcome(apps, __): IshtarSiteProfile = apps.get_model("ishtar_common", "IshtarSiteProfile") old_language = translation.get_language() translation.activate(settings.LANGUAGE_CODE) homepage = Template(HOMEPAGE_DEFAULT).render(Context({}, use_l10n=True)) title = str(HOMEPAGE_TITLE) translation.activate(old_language) for profile in IshtarSiteProfile.objects.all(): changed = False if not profile.homepage: changed = True profile.homepage = homepage if not profile.homepage_title: changed = True profile.homepage_title = title if changed: profile.save() class Migration(migrations.Migration): dependencies = [ ('ishtar_common', '0250_profile_homepage'), ] operations = [ migrations.RunPython(default_welcome) ]