Use app registry instead of INSTALLED_APPS to discover celery tasks (#754)

* Use app registry instead of INSTALLED_APPS to discover celery tasks. Fixes #717

* Added Daniel Hepper to contributors list
This commit is contained in:
Daniel Hepper 2016-09-10 13:33:25 +02:00 committed by Jannis Gebauer
parent b2207f5768
commit 12aed4724e
2 changed files with 5 additions and 2 deletions

View File

@ -70,6 +70,7 @@ Listed in alphabetical order.
Cristian Vargas `@cdvv7788`_
Cullen Rhodes `@c-rhodes`_
Dan Shultz `@shultz`_
Daniel Hepper `@dhepper`_ @danielhepper
Daniele Tricoli `@eriol`_
David Díaz `@ddiazpinto`_ @DavidDiazPinto
Davur Clementsen `@dsclementsen`_ @davur
@ -158,6 +159,7 @@ Listed in alphabetical order.
.. _@Collederas: https://github.com/Collederas
.. _@ddiazpinto: https://github.com/ddiazpinto
.. _@dezoito: https://github.com/dezoito
.. _@dhepper: https://github.com/dhepper
.. _@dot2dotseurat: https://github.com/dot2dotseurat
.. _@dsclementsen: https://github.com/dsclementsen
.. _@epileptic-fish: https://gihub.com/epileptic-fish

View File

@ -2,7 +2,7 @@
from __future__ import absolute_import
import os
from celery import Celery
from django.apps import AppConfig
from django.apps import apps, AppConfig
from django.conf import settings
@ -22,7 +22,8 @@ class CeleryConfig(AppConfig):
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
app.autodiscover_tasks(lambda: installed_apps, force=True)
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
if hasattr(settings, 'RAVEN_CONFIG'):