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


Python Entry.category方法代码示例

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


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

示例1: init_data

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import category [as 别名]
def init_data(**kwargs):
    link=Link(text="dengmin's blog",href="http://www.iyouf.info")
    link.save()
    
    default_cate=Category(name=u'未分类',slug='default',desc=u'未分类')
    default_cate.save()
    
    entry=Entry(title='Hello World!',content='<b>Hello World, welcome to use youflog! thank you!</a>',tags='youflog')
    entry.allow_comment=True
    entry.slug='hello-world'
    entry.category=default_cate
    entry.author_id=1
    entry.save(True)
    
    comment=Comment(author='admin',email='[email protected]',weburl='http://iyouf.info',content=u'测试第一条评论')
    comment.content_object=entry
    comment.save()
开发者ID:Spoylerman,项目名称:libaoyinblog,代码行数:19,代码来源:management.py

示例2: metaWeblog_newPost

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import category [as 别名]
def metaWeblog_newPost(blogid, username, password, struct, publish):
    user = User.objects.get(username__exact=username)
    if struct.has_key('title') and struct.has_key('description'):
        post = Entry(title=struct['title'],content = struct['description'])
        post.author=user
        if struct.has_key('categories'):
            catename = struct['categories'][0]
            cate=Category.objects.get(name__exact=catename)
            post.category=cate
        else:
            post.category_id=1
        if struct.has_key('mt_keywords'):
            post.tags=struct['mt_keywords']
        if struct.has_key('wp_slug'):
            post.slug=struct['wp_slug']
        post.save(True)
    return ""
开发者ID:Spoylerman,项目名称:libaoyinblog,代码行数:19,代码来源:rpc.py

示例3: submit_post

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import category [as 别名]
def submit_post(request):
    published=False
    if request.method == 'POST':
        title = request.POST['title']
        content=request.POST.get('content','')
        excerpt = request.POST.get('excerpt','')
        category_id = request.POST.get("category",1)
        tags = request.POST.get('tags','')
        slug=request.POST.get('slug','')
        allow_comment = request.POST.get('allow_comment',False)
        allow_pingback = request.POST.get('allow_pingback',False)
        action=request.POST.get('action','')
        posttype=request.POST.get('posttype','post')
        sticky=request.POST.get('sticky',False)
        
        sticky= True and sticky=='sticky'
        allow_comment= True and allow_comment == 'open'
        allow_pingback= True and allow_pingback == 'open'
        
        if request.POST.get('publish'):
            published = True
        elif request.POST.get('unpublish'):
            published = False
        else:
            published = request.POST.get('published')=='True'
        
        
        category=Category.objects.get(id=int(category_id))
        
        ctx={'action':action}
        
        if not (title and content):
            ctx.update({'msg':'Please input title and content.'})
            return render_response(request,"admin/post.html",ctx)
        
        if action== 'add':
            entry = Entry(title=title,content=content,excerpt=excerpt,\
                          category=category,slug=slug.replace(" ","-"))
            entry.tags=tags
            entry.allow_comment=allow_comment
            entry.allow_pingback=allow_pingback
            entry.entrytype=posttype
            entry.sticky=sticky
            entry.author=request.user
            if posttype and posttype =='page':
                menu_order=request.POST.get('order',0)
                if menu_order:
                    entry.menu_order=menu_order 
            
            entry.date=datetime.now()
            entry.save(published)
            
            def mapcategoy(cat):
                return  {"id":cat.id,"name":cat.name,\
                         "slug":cat.slug,"select":cat.id == int(category_id)}
            
            ctx.update({'action':'edit','entry':entry,\
                        'entrytype':posttype,'cats':map(mapcategoy,Category.objects.all())})
            
        elif action== 'edit':
            postid = request.POST.get('postid','')
            if postid:
                entry = Entry.objects.get(id=postid)
                entry.tags=tags
                entry.title=title
                entry.content=content
                entry.excerpt=excerpt
                entry.slug=slug.replace(" ","-")
                entry.entrytype=posttype
                entry.sticky=sticky
                entry.category=category
                entry.allow_pingback=allow_pingback
                if posttype and posttype =='page':
                    menu_order=request.POST.get('order',0)
                    entry.menu_order=menu_order
                entry.allow_comment=allow_comment
                entry.save(published)
                def mapcategoy(cat):
                    return  {"id":cat.id,"name":cat.name,"slug":cat.slug,"select":cat.id == entry.category.id}
    
                ctx.update({'action':'edit','entry':entry,\
                    'entrytype':posttype,'cats':map(mapcategoy,Category.objects.all())})
        else:
            pass
        
    return render_response(request,"admin/post.html",ctx)
开发者ID:zhigoo,项目名称:youflog,代码行数:88,代码来源:admin.py


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