title: How to use Flask-APScheduler in existed Flask app
body: <p>I am trying to get familiar with Flask-APScheduler plug-in through the following sample code: <a href="https://github.com/viniciuschiele/flask-apscheduler/blob/master/examples/jobs.py#L1" rel="noreferrer">https://github.com/viniciuschiele/flask-apscheduler/blob/master/examples/jobs.py#L1</a></p>
  
  <p>My project has the following structure:</p>
  
  <pre><code>backend
      run.py
      application
          __init__.py
          utilities
              __init__.py
              views
              models
  </code></pre>
  
  <p>where,</p>
  
  <p><code>backend&gt;run.py</code> is:</p>
  
  <pre><code>from application import app
  app.run(debug=True)
  from application import scheduler
  scheduler.start()
  </code></pre>
  
  <p><code>backend&gt;application&gt;__init__.py</code> is:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  from application.utilities.views import Config
  from flask_apscheduler import APScheduler
  app.config.from_object(Config())
  scheduler = APScheduler()
  scheduler.init_app(app)
  </code></pre>
  
  <p><code>backend&gt;application&gt;utilities&gt;__init__.py</code> is empty</p>
  
  <p><code>backend&gt;application&gt;utilities&gt;models.py</code> is empty</p>
  
  <p><code>backend&gt;application&gt;utilities&gt;views.py</code> is:</p>
  
  <pre><code>class Config(object):
      JOBS = [
          {
              'id': 'job1',
              'func': 'application:utilities:views:job1',
              'args': (1, 2),
              'trigger': {
                  'type': 'cron',
                  'second': 10
              }
          }
      ]
  
  def job1(a, b):
      print(str(a) + ' ' + str(b))
  </code></pre>
  
  <p>However, I get the following error:</p>
  
  <pre><code>(env)$ python run.py local
  Traceback (most recent call last):
    File "run.py", line 1, in &lt;module&gt;
      from application import app
    File "HOME/backend/application/__init__.py", line 106, in &lt;module&gt;
      scheduler.init_app(app)
    File "/home/xxxxxx/.anaconda/envs/env/lib/python2.7/site-packages/flask_apscheduler/scheduler.py", line 73, in init_app
      self.__load_jobs(app)
    File "/home/xxxxxx/.anaconda/envs/env/lib/python2.7/site-packages/flask_apscheduler/scheduler.py", line 136, in __load_jobs
      self.__load_job(job, app)
    File "/home/xxxxxx/.anaconda/envs/env/lib/python2.7/site-packages/flask_apscheduler/scheduler.py", line 159, in __load_job
      func = ref_to_obj(func)
    File "/home/xxxxxx/.anaconda/envs/env/lib/python2.7/site-packages/apscheduler/util.py", line 264, in ref_to_obj
      raise LookupError('Error resolving reference %s: error looking up object' % ref)
  LookupError: Error resolving reference application:utilities:views:job1: error looking up object
  </code></pre>
  
  <p>Does my structure look like ok? Have a placed the right code in the right place? What should I change to make it work?</p>