title: Flask config class
body: <p>I am trying to setup config classes for my project but i cant seem to figure out how to import them properly. </p>
  
  <p>Project structure:</p>
  
  <pre><code>-project
    -instance
      -config.py
    -service
      -__init__.py
  </code></pre>
  
  <p>config.py:</p>
  
  <pre><code>class DefaultConfig(object):
      DEBUG = True
  
  class ProductionConfig(DefaultConfig):
      DEBUG = False
  </code></pre>
  
  <p><strong>init</strong>.py:</p>
  
  <pre><code>from flask import Flask
  
  def create_app():
      app = Flask(__name__, instance_relative_config=True)
      app.config.from_object('config.ProductionConfig')    
      return app
  </code></pre>
  
  <p>To run the app i did:</p>
  
  <pre><code>set FLASK_APP=service
  set FLASK_ENV=production
  FLASK run
  </code></pre>
  
  <p>While standing in the <code>project</code> folder</p>
  
  <p>That gives me this error:</p>
  
  <pre><code>ImportStringError: import_string() failed for 'config'. Possible reasons are:
  
  - missing __init__.py in a package;
  - package or module path not included in sys.path;
  - duplicated package or module name taking precedence in sys.path;
  - missing module, class, function or variable;
  
  Debugged import:
  
  - 'config' not found.
  
  Original exception:
  
  ModuleNotFoundError: No module named 'config'
  </code></pre>
  
  <p>My guess is that the path is not right. 
  I followed <a href="http://flask.pocoo.org/docs/0.12/config/" rel="nofollow noreferrer">this</a> example, where they talk about using inheritance for configuration and instance folders. It made alot of sense when i read it but i must have managed to missinterpret an integral part.  </p>
  
  <p>EDIT: Now it works. Instead of just</p>
  
  <pre><code>app.config.from_object('config.DefaultConfig')
  </code></pre>
  
  <p>i had to do </p>
  
  <pre><code>app.config.from_object('instance.config.DefaultConfig')
  </code></pre>
  
  <p>I think that is really confusing because setting the <code>instance_relative_config</code> to True like i did, should according to the docs set the path for the config files relative to the instance directory. Now i am accessing them relative to the project root... </p>