我在ubuntu流浪盒中运行python
每当我运行 runserver 或 syncdb 时,我都会收到此错误。
应用程序未在数据库实例上注册且没有应用程序
完整筹码:
<div class="col-sm-4 rating">
<input type="hidden" name="questionId[]" value="4"/>
<input type="radio" class="career_ratings" id="career_star31" name="career_rating_answer[3]" value="1" />
<label for="career_star31" title=""></label>
<input type="radio" class="career_ratings" id="career_star32" name="career_rating_answer[3]" value="2"/>
<label for="career_star32" title=""></label>
<input type="radio" class="career_ratings" id="career_star33" name="career_rating_answer[3]" value="3"/>
<label for="career_star33" title=""></label>
<input type="radio" class="career_ratings" id="career_star34" name="career_rating_answer[3]" value="4"/>
<label for="career_star34" title=""></label>
</div>
在manage.py中发生错误:
Traceback (most recent call last): File "manage.py", line 41, in <module>
models.PSABase.metadata.create_all(db.engine) File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 922, in engine
return self.get_engine() File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 931, in get_engine
app = self.get_app(app) File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 957, in get_app
'application not registered on db instance and no application' RuntimeError: application not registered on db instance and no applicationbound to current context
答案 0 :(得分:0)
我说:
from pixelpin_auth_flask_sqlalchemy import models
models.PSABase.metadata.create_all(db.engine)
错误的地方应该是:
@manager.command
def syncdb():
User.metadata.create_all(db.engine)
from pixelpin_auth_flask_sqlalchemy import models
models.PSABase.metadata.create_all(db.engine)
manager.add_command('server', Server(host='192.168.33.16'))
manager.add_command('shell', Shell(make_context=_make_context))
if __name__ == '__main__':
manager.add_command("runserver", Server(
use_debugger = True,
use_reloader = True,
host = '192.168.33.16'))
manager.run()