Randy Tang
Randy Tang

Reputation: 4353

Heroku apscheduler: schedule a cron job of URL request

I am following this document to schedule a cron job for my Django application. The following is the clock.py:

from apscheduler.schedulers.blocking import BlockingScheduler
from django.shortcuts import redirect

sched = BlockingScheduler()

@sched.scheduled_job('interval', minutes=60)
def timed_job():
    return redirect('http://example.com/')

sched.start()

Heroku shows the following error message:

django.core.exceptions.ImproperlyConfigured:
Requested setting ROOT_URLCONF, but settings are not configured. You
 must either define the environment variable DJANGO_SETTINGS_MODULE or
 call settings.configure() before accessing settings. 

I have no idea about what the error message means. My questions:

  1. I put the clock.py under the project root directory. Is it correct?
  2. How do I schedule a URL-request job?

Upvotes: 2

Views: 643

Answers (1)

metakermit
metakermit

Reputation: 22311

The error message seems more like something related to how your project is structured, something outside of clock.py. Does some basic hello world view work when you open it in your browser? Do you have a settings.py file in place? Also check out the basic Django on Heroku tutorial and maybe try building from there to get the scheduling to work.

Upvotes: 1

Related Questions