我跟着一本书尝试创建Flask博客。我是Flask的新手。我更新了一个模型,因此代码如下所示:
class Entry(db.Model):
STATUS_PUBLIC = 0
STATUS_DRAFT = 1
STATUS_DELETED = 2
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100))
slug = db.Column(db.String(100), unique=True)
body = db.Column(db.Text)
status = db.Column(db.SmallInteger, default=STATUS_PUBLIC)
created_timestamp = db.Column(db.DateTime, default=datetime.datetime.now)
modified_timestamp = db.Column(
db.DateTime,
default=datetime.datetime.now,
onupdate=datetime.datetime.now)
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
Run Code Online (Sandbox Code Playgroud)
添加最后一行author_id = db.Column(db.Integer, db.ForeignKey("user.id"))会导致数据库升级失败,并显示以下错误:
File "manage.py", line 5, in <module>
manager.run()
File "/home/devblog/projects/blog/venv/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/home/devblog/projects/blog/venv/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/home/devblog/projects/blog/venv/lib/python2.7/site-packages/flask_script/commands.py", line …Run Code Online (Sandbox Code Playgroud) 我尝试安装 PyLint。安装时我看到以下内容:
\n\nCollecting pylint\n Downloading pylint-1.6.5-py2.py3-none-any.whl (577kB)\n 100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 583kB 655kB/s \nCollecting six (from pylint)\n Using cached six-1.10.0-py2.py3-none-any.whl\nCollecting isort>=4.2.5 (from pylint)\n Downloading isort-4.2.5-py2.py3-none-any.whl (40kB)\n 100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 40kB 737kB/s \nCollecting mccabe (from pylint)\n Downloading mccabe-0.6.1-py2.py3-none-any.whl\nCollecting configparser; python_version == "2.7" (from pylint)\n Downloading configparser-3.5.0.tar.gz\nCollecting backports.functools-lru-cache; python_version == "2.7" (from pylint)\n Downloading backports.functools_lru_cache-1.3-py2.py3-none-any.whl\nCollecting astroid<1.5.0,>=1.4.5 (from pylint)\n Downloading astroid-1.4.9-py2.py3-none-any.whl (213kB)\n 100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 215kB 713kB/s \nCollecting lazy-object-proxy (from astroid<1.5.0,>=1.4.5->pylint)\n Downloading lazy-object-proxy-1.2.2.tar.gz\nCollecting wrapt (from astroid<1.5.0,>=1.4.5->pylint)\n Downloading wrapt-1.10.8.tar.gz\nBuilding wheels for collected packages: configparser, lazy-object-proxy, wrapt\n Running …Run Code Online (Sandbox Code Playgroud)