本文整理汇总了Python中app.models.Comment.generate_comments方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.generate_comments方法的具体用法?Python Comment.generate_comments怎么用?Python Comment.generate_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Comment
的用法示例。
在下文中一共展示了Comment.generate_comments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recreate_data
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import generate_comments [as 别名]
def recreate_data():
"""Generate fake data for development and testing"""
print 'dropping existing tables...'
db.drop_all()
print 'creating tables...'
db.create_all()
print 'inserting roles...'
Role.insert_roles()
print 'creating admin user...'
u1 = User(username='ralph', email='[email protected]', password='r',
name='Ralph Wen', location='Hangzhou, China',
about_me='This is the creator of everything', confirmed=True)
db.session.add(u1)
print 'creating moderate user...'
u2 = User(username='yadong', email='[email protected]', password='r',
name='Yadong Wen', location='Hangzhou, China',
about_me='Yeah', confirmed=True)
db.session.add(u2)
db.session.commit()
print 'generating 50 normal users...'
User.generate_fake(50)
print 'generating 500 posts...'
Post.generate_fake(500)
print 'generating follows...'
User.generate_following()
print 'generating comments...'
Comment.generate_comments()
print '...done'
示例2: create_app
# 需要导入模块: from app.models import Comment [as 别名]
# 或者: from app.models.Comment import generate_comments [as 别名]
from app import create_app, db
from app.models import User, Role, Post, Follow, Comment
from flask.ext.script import Manager, Shell
from flask.ext.migrate import Migrate, MigrateCommand
app = create_app('default')
manager = Manager(app)
migrate = Migrate(app, db)
def make_shell_context():
return dict(app=app, db=db, User=User, Role=Role, Post=Post, Follow=Follow, Comment=Comment)
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
#数据库迁移指令
'''
脚本命令 cd E:\Python_project\Flasky
python manage.py runserver --host 0.0.0.0
创建数据库迁移仓库: python manage.py db init
迁移脚本 python manage.py db migrate -m "initial migration"
更新数据库: python manage.py db upgrade
#运行脚本环境 python manage.py shell
Comment.generate_comments()
http://gravatar.com/avatar/
http://gravatar.com/avatar/4bc7e8834a6fd8f9334ef878ad58ecf5
'''
if __name__ == '__main__':
#app.run(host = '0.0.0.0')