title: How to programmatically generate celerybeat entries with celery and Django
body: <p>I am hoping to be able to programmatically generate celerybeat entries and resync celerybeat when entries are added.  The docs <a href="http://ask.github.com/celery/userguide/periodic-tasks.html">here</a> state </p>
  
  <blockquote>
    <p>By default the entries are taken from the CELERYBEAT_SCHEDULE setting, but custom stores can also be used, like storing the entries in an SQL database.</p>
  </blockquote>
  
  <p>So I am trying to figure out which classes i need to extend to be able to do this.</p>
  
  <p>I have been looking at <a href="http://ask.github.com/celery/internals/reference/celery.beat.html">celery scheduler docs</a> and <a href="http://ask.github.com/django-celery/reference/djcelery.schedulers.html">djcelery api docs</a> but the documentation on what some of these methods do is non-existent so about to dive into some source and was just hoping someone could point me in the right direction.</p>
  
  <p>I guess a high level of what I'm doing would be helpful... As a user I need to be able to select from a predefined set of tasks and provide a way for a user to select some sort of custom schedule for it to execute, like every day/week/month and what day and time.</p>
  
  <p>Also this is in Django with djcelery.</p>
  
  <p><strong>UPDATE</strong>  </p>
  
  <p>I see the code for the djcelery admin but am not clear on how that data is being persisted.  I currently have a generic <code>addTask</code> view that looks like this :</p>
  
  <pre><code>def addTask(request):
  
  intervalSchedule = IntervalSchedule.from_schedule(schedule(timedelta(seconds=10)))
  intervalSchedule.save()
  modelData = dict(
      name="dcTestPersist",
      task="technologytrackerapi.views.createRecord",
      schedule=intervalSchedule,
  )
  periodicTask = PeriodicTask(**modelData)
  periodicTask.save()
  return render_to_response('taskView.html')
  </code></pre>
  
  <p>The data looks correct in the db but when the daemon runs it has this error :</p>
  
  <blockquote>
    <p>[2012-03-06 00:23:07,926: WARNING/Beat] Process Beat:<br>
    [2012-03-06 00:23:07,926: WARNING/Beat] Traceback (most recent call last):<br>
    [2012-03-06 00:23:07,926: WARNING/Beat] File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap<br>
    [2012-03-06 00:23:07,926: WARNING/Beat] self.run()<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] File "/home/dchesterman/Documents/PythonDev/.virtualenvs/ros/local/lib/python2.7/site-packages/celery/beat.py", line 464, in run<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] self.service.start(embedded_process=True)<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] File "/home/dchesterman/Documents/PythonDev  /.virtualenvs/ros/local/lib/python2.7/site-packages/celery/beat.py", line 403, in start<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] interval = self.scheduler.tick()<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] File "/home/dchesterman/Documents/PythonDev/.virtualenvs/ros/local/lib/python2.7/site-packages/celery/beat.py", line 194, in tick<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] next_time_to_run = self.maybe_due(entry, self.publisher)<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] File "/home/dchesterman/Documents/PythonDev/.virtualenvs/ros/local/lib/python2.7/site-packages/celery/beat.py", line 170, in maybe_due<br>
    [2012-03-06 00:23:07,927: WARNING/Beat] is_due, next_time_to_run = entry.is_due()<br>
    [2012-03-06 00:23:07,928: WARNING/Beat] File "/home/dchesterman/Documents/PythonDev/.virtualenvs/ros/local/lib/python2.7/site-packages/djcelery/schedulers.py", line 54, in is_due<br>
    [2012-03-06 00:23:07,928: WARNING/Beat] return self.schedule.is_due(self.last_run_at)<br>
    [2012-03-06 00:23:07,928: WARNING/Beat] AttributeError: 'NoneType' object has no attribute 'is_due'  </p>
  </blockquote>
  
  <p>I'm not sure why my schedule does not use the default <code>is_due()</code></p>