【发布时间】:2015-05-31 12:47:27
【问题描述】:
这是我的 models.py 文件中的代码。一切正常,直到我尝试为“ID”添加一个新字段,该字段随每个项目递增。这是一个在谷歌应用引擎上运行的烧瓶应用。
from google.appengine.ext import db
class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.StringProperty(required = True)
content = db.TextProperty(required = True)
这是我得到的回溯:
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'Column'
Traceback (most recent call last):
File "/base/data/home/apps/s~smart-cove-95709/1.384688470778541604/main.py", line 2, in <module>
from blog import app
File "/base/data/home/apps/s~smart-cove-95709/1.384688470778541604/blog/__init__.py", line 7, in <module>
import views
File "/base/data/home/apps/s~smart-cove-95709/1.384688470778541604/blog/views.py", line 2, in <module>
from models import Post
File "/base/data/home/apps/s~smart-cove-95709/1.384688470778541604/blog/models.py", line 3, in <module>
class Post(db.Model):
File "/base/data/home/apps/s~smart-cove-95709/1.384688470778541604/blog/models.py", line 4, in Post
id = db.Column(db.Integer, primary_key=True)
我也试过了,但没有成功:
class Post(db.Model):
id = db.Integer(primary_key=True)
title = db.StringProperty(required = True)
content = db.TextProperty(required = True)
【问题讨论】:
标签: python google-app-engine flask