title: Django Celery Received unregistered task of type 'appname.tasks.add'
body: <p>Following the documentation and the Demo Django project here <a href="https://github.com/celery/celery/tree/3.1/examples/django" rel="noreferrer">https://github.com/celery/celery/tree/3.1/examples/django</a></p>
  
  <p><strong>Project Structure</strong></p>
  
  <pre><code>piesup2
      |
      piesup2
      |  |__init__.py
      |  |celery.py
      |  |settings.py
      |  |urls.py
      reports
         |tasks.py
         |models.py
         |etc....
  </code></pre>
  
  <p><strong>My Code</strong></p>
  
  <p><code>piesup2/celery.py</code></p>
  
  <pre><code>from __future__ import absolute_import
  
  import os
  
  from celery import Celery
  
  # set the default Django settings module for the 'celery' program.
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'piesup2.settings')
  
  from django.conf import settings  # noqa
  
  app = Celery('piesup2')
  
  # 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)
  
  
  @app.task(bind=True)
  def debug_task(self):
      print('Request: {0!r}'.format(self.request))
  </code></pre>
  
  <p><code>piesup2/__init__.py</code></p>
  
  <pre><code>from __future__ import absolute_import
  
  # This will make sure the app is always imported when
  # Django starts so that shared_task will use this app.
  from .celery import app as celery_app  # noqa
  </code></pre>
  
  <p><code>piesup2/reports/tasks.py</code></p>
  
  <pre><code>from __future__ import absolute_import
  
  from celery import shared_task
  
  
  @shared_task
  def add(x, y):
      return x + y
  </code></pre>
  
  <p>After starting Celery from the command line with: </p>
  
  <pre><code>celery -A piesup2 worker -l info
  </code></pre>
  
  <p>When I attempt to run a task from within my models.py file like this:</p>
  
  <pre><code> def do_stuff(self):
      from reports.tasks import add
      number = add.delay(2, 2)
      print(number)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>[2016-08-05 16:50:31,625: ERROR/MainProcess] Received unregistered
    task of type 'reports.tasks.add'. The message has been ignored and
    discarded.</p>
    
    <p>Did you remember to import the module containing this task? Or maybe
    you are using relative imports? Please see <a href="http://docs.celeryq.org/en/latest/userguide/tasks.html#task-names" rel="noreferrer">http://docs.celeryq.org/en/latest/userguide/tasks.html#task-names</a> for
    more information.</p>
    
    <p>The full contents of the message body was: {'callbacks': None,
    'retries': 0, 'chord': None, 'errbacks': None, 'task':
    'reports.tasks.add', 'args': [2, 2], 'timelimit': [None, None],
    'kwargs': {}, 'id': 'b12eb387-cf8c-483d-b53e-f9ce0ad6b421', 'taskset':
    None, 'eta': None, 'expires': None, 'utc': True} (258b) Traceback
    (most recent call last):   File
    "/home/jwe/piesup2/venv/lib/python3.4/site-packages/celery/worker/consumer.py",
    line 456, in on_task_received
        strategies[name](message, body, KeyError: 'reports.tasks.add'</p>
  </blockquote>