diff --git a/django_dramatiq/apps.py b/django_dramatiq/apps.py index 0cee071..321d7bf 100644 --- a/django_dramatiq/apps.py +++ b/django_dramatiq/apps.py @@ -35,21 +35,8 @@ class DjangoDramatiqConfig(AppConfig): name = "django_dramatiq" verbose_name = "Django Dramatiq" - def import_models(self): - """ - Initialize Dramatiq configuration right after Django has loaded its models. - - Django calls `ready()` on all apps only after it has loaded all models. - Due to the fact that tasks often imported from models, we need to make sure - that Dramatiq is fully configured before that happens. - """ - super().import_models() - self.ready() - - def ready(self): - if getattr(self, "_is_ready", False): - return - super().ready() + def __init__(self, app_name, app_module): + super().__init__(app_name, app_module) global RATE_LIMITER_BACKEND dramatiq.set_encoder(self.select_encoder()) @@ -91,8 +78,6 @@ def ready(self): broker = broker_class(middleware=middleware, **broker_options) dramatiq.set_broker(broker) - self._is_ready = True - @property def rate_limiter_backend(self): return type(self).get_rate_limiter_backend()