当前位置: 首页>>代码示例>>Python>>正文


Python Account.objects方法代码示例

本文整理汇总了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")
开发者ID:princenju,项目名称:ebayWithVoice,代码行数:13,代码来源:views.py

示例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))
开发者ID:princenju,项目名称:ebayWithVoice,代码行数:27,代码来源:views.py

示例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))
开发者ID:PauloDuarte43,项目名称:tomada-social,代码行数:9,代码来源:views.py

示例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))
开发者ID:princenju,项目名称:ebayWithVoice,代码行数:21,代码来源:views.py

示例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")
开发者ID:princenju,项目名称:ebayWithVoice,代码行数:7,代码来源:views.py

示例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()
开发者ID:LukeZhao,项目名称:misc,代码行数:33,代码来源:clean_staled_redis_keys.py

示例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
开发者ID:PauloDuarte43,项目名称:tomada-social,代码行数:6,代码来源:views.py


注:本文中的models.Account.objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。