from django.apps import AppConfig
from django.conf import settings
from django.db.models.signals import post_migrate


def update_default_site(sender, **kwargs):
    from django.contrib.sites.models import Site

    site = Site.objects.get_current()
    site.domain = settings.HOST_NAME
    site.name = "FET"
    site.save()


class CoreConfig(AppConfig):
    name = "core"

    def ready(self):
        post_migrate.connect(update_default_site, sender=self)
