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


Python Profile.objects方法代码示例

本文整理汇总了Python中models.Profile.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.objects方法的具体用法?Python Profile.objects怎么用?Python Profile.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Profile的用法示例。


在下文中一共展示了Profile.objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import objects [as 别名]
def update(request):
    id = eval("request." + request.method + "['id']")
    if Post.objects(id=id):
        post = Post.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            post.title = request.POST['title']
            #str_date_published = request.POST['date_published']
            #post.date_published = datetime.fromtimestamp(mktime(time.strptime(str_date_published, "%b %d %Y")))
            post.publisher = request.POST['publisher']
            post.papertype = request.POST['papertype']
            post.authors = request.POST['authors']
            #post.additional_info = request.POST['additional_info']
            #post.page_num = request.POST['page_num']
            #if request.POST.get('selectedpublication', True):
            #    post.selectedpublication = True;
            post.save()
            params = {'Posts': Post.objects} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'post':post}
    
    elif Section.objects(id=id):
        section = Section.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            section.heading = request.POST['heading']
            section.content = request.POST['content']
            section.save()
            params = {'Sections': Section.objects} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'section':section}
            
    elif Profile.objects(id=id):
        profile = Profile.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            profile.details = request.POST['profile']
            profile.save()
            params = {'Profile': Profile.objects.limit(1)} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'Profile': Profile.objects.limit(1)}

    return render_to_response(template, params, context_instance=RequestContext(request))
开发者ID:micadeyeye,项目名称:Blongo,代码行数:54,代码来源:views.py

示例2: delete

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import objects [as 别名]
def delete(request):
    id = eval("request." + request.method + "['id']")

    if request.method == 'POST':
        template = 'admin/index.html'
        if Post.objects(id=id):
            post = Post.objects(id=id)[0]
            post.delete()
            params = {'Posts': Post.objects, 'Sections': Section.objects, 'Profile': Profile.objects.limit(1)} 
        elif Section.objects(id=id):
            section = Section.objects(id=id)[0]
            section.delete()            
            params = {'Sections': Section.objects, 'Posts': Post.objects, 'Profile': Profile.objects.limit(1)} 
        elif Profile.objects(id=id):
            profile = Profile.objects(id=id)[0]
            profile.delete()            
            params = {'Profile': Profile.objects.limit(1), 'Sections': Section.objects, 'Posts': Post.objects} 
    elif request.method == 'GET':
        template = 'admin/delete.html'
        params = { 'id': id } 

    return render_to_response(template, params, context_instance=RequestContext(request))
开发者ID:micadeyeye,项目名称:Blongo,代码行数:24,代码来源:views.py


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