title: Celery-beat: why it doesn't work in Django?
body: <p>Task itself works well(run asynchronously), but when I trying using <code>celery beat</code> it doesn't work.</p>
  
  <p>I followed <a href="http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#beat-custom-schedulers" rel="nofollow noreferrer">http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#beat-custom-schedulers</a>. </p>
  
  <p>This is my <code>django</code> project structure:</p>
  
  <pre><code>.
  . 
  ├── clien
  │   ├── __init__.py
  │   ├── admin.py
  │   ├── management
  │   │   ├── __init__.py
  │   │   └── commands
  │   │       ├── __init__.py
  │   │       └── crawl_clien.py
  │   ├── migrations
  │   ├── models.py
  │   ├── tasks
  │   │   ├── __init__.py           ## ==&gt; code
  │   │   └── crawl_clien_task.py   ## ==&gt; code
  │   ├── templates
  │   ├── urls.py
  │   └── views
  ├── config
  │   ├── __init__.py     ## ==&gt; code
  │   ├── celery.py       ## ==&gt; code
  │   ├── settings
  │   │   ├── __init__.py
  │   │   ├── partials
  │   │   │   ├── __init__.py
  │   │   │   ├── base.py 
  │   ├── urls.py
  │   └── wsgi.py
  ├── manage.py
  .
  .
  </code></pre>
  
  <p>Only <code>clien</code> is registered in <code>app</code>. Here are the codes:</p>
  
  <p><strong>config/celery.py</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  from celery.schedules import crontab
  
  app = Celery('chois_crawler')
  app.config_from_object('django.conf:settings', namespace='CELERY')
  app.autodiscover_tasks()
  app.conf.beat_schedule = {
      'my_task': {
          'task': 'tasks.crawl_clien_task',
          'schedule': crontab(minute='*/1'),
      },
  }
  </code></pre>
  
  <p><strong>config/__init__.py</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  from .celery import app as celery_app
  __all__ = ['celery_app']
  </code></pre>
  
  <p><strong>clien/tasks/crawl_clien_task.py</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  from celery import shared_task, Celery
  from clien.management.commands import crawl_clien
  
  @shared_task
  def crawl_clien_task():
      print("hi")
  </code></pre>
  
  <p><strong>clien/tasks/__init__.py</strong></p>
  
  <pre><code>from .crawl_clien_task import *
  </code></pre>
  
  <p>It doesn't work... </p>
  
  <p>It showed error : </p>
  
  <pre><code>[2017-05-02 09:58:00,027: ERROR/MainProcess] Received unregistered task of type 'tasks.crawl_clien_task'.
  The message has been ignored and discarded.
  
  Did you remember to import the module containing this task?
  Or maybe you're using relative imports?
  
  Please see
  http://docs.celeryq.org/en/latest/internals/protocol.html
  for more information.
  
  The full contents of the message body was:
  b'[[], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (77b)
  Traceback (most recent call last):
    File "/Users/Chois/.pyenv/versions/3.5.1/envs/chois_crawler/lib/python3.5/site-packages/celery/worker/consumer/consumer.py", line 559, in on_task_received
      strategy = strategies[type_]
  KeyError: 'tasks.crawl_clien_task'
  </code></pre>
  
  <p>So I choose the other way:</p>
  
  <p><strong>config/celery.py</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  
  app = Celery('chois_crawler')
  app.config_from_object('django.conf:settings', namespace='CELERY')
  app.autodiscover_tasks()
  </code></pre>
  
  <p><strong>tasks/crawl_clien_task.py</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  from celery import shared_task
  from celery.schedules import crontab
  from config.celery import app
  
  @app.on_after_configure.connect
  def setup_periodic_tasks(sender, **kwargs):
      sender.add_periodic_task(
          crontab(minute='*/5'),
          crawl_clien_task(),
          name="hi",
      )
  
  @shared_task
  def crawl_clien_task():
      print("hi")
  </code></pre>
  
  <p>But it doesn't work, either!</p>
  
  <p>What's wrong with it?</p>