# Generated by Django 2.2.20 on 2021-08-25 08:18
from django.db import migrations
from bluebottle.clients import properties


def set_default(apps, schema_editor):
    try: 
        Language = apps.get_model('utils', 'Language')

        language = Language.objects.get(code=properties.LANGUAGE_CODE)
    except Language.DoesNotExist:
        language = Language.objects.first()

    language.default = True
    language.save()


class Migration(migrations.Migration):

    dependencies = [
        ('utils', '0006_auto_20210825_1018'),
    ]

    operations = [
        migrations.RunPython(set_default, migrations.RunPython.noop)
    ]

# Generated by Django 2.2.20 on 2021-08-25 08:18
from django.db import migrations
from bluebottle.clients import properties


def set_default(apps, schema_editor):
    try: 
        Language = apps.get_model('utils', 'Language')

        language = Language.objects.get(code=properties.LANGUAGE_CODE)
    except Language.DoesNotExist:
        try:
            language = Language.objects.get()
        except Language.DoesNotExist:
            return

    language.default = True
    language.save()


class Migration(migrations.Migration):

    dependencies = [
        ('utils', '0006_auto_20210825_1018'),
    ]

    operations = [
        migrations.RunPython(set_default, migrations.RunPython.noop)
    ]

Fix migration if no language exists
Fix migration if no language exists
