from django.apps import AppConfig


class DjangoDevicehubConfig(AppConfig):
    name = "django_devicehub"
    default_auto_field = "django.db.models.BigAutoField"
    verbose_name = "Django DeviceHub"

    def ready(self):
        # Auto-discover devices.py modules in installed apps
        from django.utils.module_loading import autodiscover_modules

        autodiscover_modules("devices")

        # Auto-register admin if configured
        from .conf import devicehub_settings

        if devicehub_settings.AUTO_ADMIN:
            from .generators.admin import auto_register_admin

            auto_register_admin()
