本文整理汇总了Python中app.users.models.User.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_id方法的具体用法?Python User.get_by_id怎么用?Python User.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.users.models.User
的用法示例。
在下文中一共展示了User.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_posts
# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get_by_id [as 别名]
def create_posts(cls):
print "*******************************************"
user = User.get_by_id(1)
if not user is None:
for i in range(1, 51):
print 'creating post # %s' % i
post = Post.create()
post.title = unicode('Title %s' % i)
post.body = unicode('Body %s' % i)
post.user = user
post.save()
print "Created Dummy Posts for %r" % user
print "*******************************************"
user = User.get_by_id(2)
if not user is None:
for i in range(1, 51):
print 'creating post # %s' % i
post = Post.create()
post.title = unicode('Title %s' % i)
post.body = unicode('Body %s' % i)
post.user = user
post.save()
print "Created Dummy Posts for %r" % user
示例2: load_user
# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get_by_id [as 别名]
def load_user(userid):
return User.get_by_id(userid)