本文整理汇总了Python中models.Account.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Account.objects方法的具体用法?Python Account.objects怎么用?Python Account.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.objects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: changeFollow
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def changeFollow(request):
name=request.GET['username']
friend=Account.objects(username=name).first()
user=Account.objects(username=request.user.username).first()
if str(friend.id) in user.friends:
user.friends.remove(str(friend.id))
else:
user.friends=user.friends+[str(friend.id)]
user.save()
request.user=user
return HttpResponse("add success")
示例2: search
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def search(request):
name=request.GET["username"]
users=Account.objects(username=name).as_pymongo()
if users.count()==0:
return HttpResponse(ju.dumps([]))
users=list(users)
for user in users:
user["portrait"]=endpoint+"users/getPortrait?id="+str(user['_id'])
del(user['buylog'])
del(user['_types'])
del(user['is_active'])
del(user['is_superuser'])
del(user['is_staff'])
del(user['last_login'])
del(user['_cls'])
del(user['password'])
del(user['friends'])
del(user['date_joined'])
id=user['_id']
if str(id) in request.user.friends:
user['followed']=True
else:
user['followed']=False
del(user['_id'])
return HttpResponse(ju.dumps(users))
示例3: list
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def list(request):
# Get all accounts from DB
accounts = Account.objects()
return render_to_response('account/account_list.html',
{'account_list': accounts,
'request':request},
context_instance=RequestContext(request))
示例4: showFriends
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def showFriends(request):
# user=Account.objects(username=request.user.username).first()
ids=request.user.friends
friends=Account.objects(pk__in=ids).as_pymongo()
friends=list(friends)
for friend in friends:
del(friend["buylog"])
del(friend["_types"])
del(friend['is_active'])
del(friend['is_superuser'])
del(friend['is_staff'])
del(friend['last_login'])
del(friend['_cls'])
del(friend['password'])
del(friend['friends'])
del(friend['date_joined'])
friend['portrait']=endpoint+"users/getPortrait?id="+str(friend['_id'])
del(friend['_id'])
return HttpResponse(ju.dumps(friends))
示例5: getPortrait
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def getPortrait(request):
nid=request.GET['id']
user=Account.objects(pk=nid).first()
return HttpResponse(user.portrait.read()
,mimetype="image/jpeg")
示例6: len
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
from main import exit
rds = redis_connection
from sockets import decode_token
from models import Account
if __name__ == '__main__':
customer = sys.argv[1] if len(sys.argv) > 1 else 'weppa'
print '-'*20, '\nCUSTOMER: {}\n'.format(customer), '-'*20
switch_customer(customer) or exit()
print '>> cleaning staled sessions:uid:*....'
cnt = 0
for key in rds.keys('sessions:uid:*'):
if rds.ttl(key) == -1:
uid = key.split(':')[2]
acc = Account.objects(id=uid).no_dereference().first()
if ((acc and acc.id.generation_time
< arrow.get().replace(days=-30))):
cnt += 1
rds.expire(key, 0)
print ' Done total cleaned: {}'.format(cnt)
print '>> cleaning staled queue:session:*....'
cnt = 0
for key in rds.keys('queue:session:*'):
if rds.ttl(key) == -1:
token = key.split(':')[2]
try:
tok = decode_token(token)
uid = tok.get('user_id')
acc = Account.objects(id=uid).no_dereference().first()
示例7: getUser
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import objects [as 别名]
def getUser(id):
# Get all accounts from DB
account = Account.objects(id=id)
return account