smurfix/flask-script

AttributeError: 'NoneType' object has no attribute 'create_parser'

avrong opened this issue · 1 comments

Command:

./manage.py db migrate

Error:

Traceback (most recent call last):
  File "./manage.py", line 23, in <module>
    manager.run()
  File "/home/avrong/virtualenv/xnblog/lib/python3.4/site-packages/flask_script/__init__.py", line 412, in run
    result = self.handle(sys.argv[0], sys.argv[1:])
  File "/home/avrong/virtualenv/xnblog/lib/python3.4/site-packages/flask_script/__init__.py", line 350, in handle
    app_parser = self.create_parser(prog)
  File "/home/avrong/virtualenv/xnblog/lib/python3.4/site-packages/flask_script/__init__.py", line 193, in create_parser
    command_parser = command.create_parser(name, func_stack=func_stack, parent=self)
AttributeError: 'NoneType' object has no attribute 'create_parser'

manage.py:

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand

from app import app
from app.models import *

migrate = Migrate(app, db)

manager = Manager(app)


def createall():
    db.create_all()

manager.add_command('runserver', Server)
manager.add_command('create', createall())
manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()

Pass the function, not the result of the function call, to add_command.

manager.add_command('create', createall)