title: Running periodic tasks with django and celery
body: <p>I'm trying create a simple background periodic task using Django-Celery-RabbitMQ combination. I installed Django 1.3.1, I downloaded and setup djcelery. Here is how my settings.py file looks like:</p>
  
  <pre><code>BROKER_HOST = "127.0.0.1"
  BROKER_PORT = 5672
  BROKER_VHOST = "/"
  BROKER_USER = "guest"
  BROKER_PASSWORD = "guest"
  ....
  import djcelery
  djcelery.setup_loader()
  ...
  INSTALLED_APPS = (
      'djcelery',
  )
  </code></pre>
  
  <p>And I put a 'tasks.py' file in my application folder with the following contents:</p>
  
  <pre><code>from celery.task import PeriodicTask
  from celery.registry import tasks
  from datetime import timedelta
  from datetime import datetime
  
  class MyTask(PeriodicTask):
      run_every = timedelta(minutes=1)
  
      def run(self, **kwargs):
          self.get_logger().info("Time now: " + datetime.now())
          print("Time now: " + datetime.now())
  
  tasks.register(MyTask)
  </code></pre>
  
  <p>And then I start up my django server (local development instance):</p>
  
  <pre><code>python manage.py runserver
  </code></pre>
  
  <p>Then I start up the <code>celerybeat</code> process:</p>
  
  <pre><code>python manage.py celerybeat --logfile=&lt;path_to_log_file&gt; -l DEBUG
  </code></pre>
  
  <p>I can see entries like this in the log:</p>
  
  <pre><code>[2012-04-29 07:50:54,671: DEBUG/MainProcess] tasks.MyTask sent. id-&gt;72a5963c-6e15-4fc5-a078-dd26da663323
  </code></pre>
  
  <p>And I also can see the corresponding entries getting created in database, but I can't find where it is logging the text I specified in the actual <code>run</code> function in <code>MyTask</code> class.</p>
  
  <p>I tried fiddling with the logging settings, tried using the django logger instead of celery logger, but of no use. I'm not even sure, my task is getting executed. If I print any debug information in the task, where does it go? </p>
  
  <p>Also, this is first time I'm working with any type of message queuing system. It looks like the task will get executed as part of the <code>celerybeat</code> process - outside the django web framework. Will I still be able to access all the django models I created.</p>
  
  <p>Thanks,
  Venkat.</p>