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


Python Category.available_list方法代码示例

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


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

示例1: get_context_data

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import available_list [as 别名]
    def get_context_data(self,*args,**kwargs):
        context = super(BaseMixin,self).get_context_data(**kwargs)

        try:
            context['categories'] = Category.available_list()
            context['widgets'] = Widget.available_list()
            context['recently_posts'] = Post.get_recently_posts(RECENTLY_NUM)
            context['hot_posts'] = Post.get_hots_posts(HOT_NUM)
            context['pages'] = Page.objects.filter(status=0)
            if cache.get('online.ips')!= None:
                context['online_num'] = len(cache.get('online_ips'))
        except Exception as e:
            logger.exception(u'加载基本信息出错[%s]',e)

        return context
开发者ID:swrite,项目名称:xiaojunBlog,代码行数:17,代码来源:views.py

示例2: get_context_data

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import available_list [as 别名]
    def get_context_data(self, *args, **kwargs):
        if 'object' in kwargs or 'query' in kwargs:
            context = super(BaseMixin, self).get_context_data(**kwargs)
        else:
            context = {}

        try:
            context['categories'] = Category.available_list()
            context['widgets'] = Widget.available_list()
            context['recently_posts'] = Post.get_recently_posts(RECENTLY_NUM)
            context['hot_posts'] = Post.get_hots_posts(HOT_NUM)
            context['tag_lists'] = Post.gather_tags()
            context['like_most_posts'] = Post.get_most_like_posts(LIKE_MOST_NUM)
            context['pages'] = Page.objects.filter(status=0)
        except Exception as e:
            logger.exception(u'加载基本信息出错[%s]!', e)

        return context
开发者ID:rjl493456442,项目名称:blog,代码行数:20,代码来源:views.py

示例3: get_base_context

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import available_list [as 别名]
 def get_base_context(self,
                      AVAILABLE_CATEGORYS_NUM=100,
                      HOT_ARTICLES_NUM=10,
                      CATEGORY=None,
                      TAG=None,
                      NUM=100
                      ):
     base_context = {}
     try:
         base_context['available_category_list'] = Category.available_list(
             AVAILABLE_CATEGORYS_NUM)
         base_context['navbar_category_list'] = Category.navbar_list()
         base_context['hot_article_list'] = Article.get_hots_articles(
             HOT_ARTICLES_NUM)
         base_context['articles_list'] = Article.get_articles(
             CATEGORY, TAG, NUM)
         base_context['all_tags_list'] = Article.get_all_tags_list()
     except Exception, e:
         raise Http404
开发者ID:WBowam,项目名称:Tblog,代码行数:21,代码来源:base_views.py

示例4: add_context_data

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import available_list [as 别名]
 def add_context_data(self, **kwargs):
     # 这里重载了ListView的get_context_data方法
     context = super(BaseMixin, self).get_context_data(**kwargs)
     try:
         context['categories'] = Category.available_list()
         context['widgets'] = Widget.available_list()
         context['recently_posts'] = Post.get_recently_posts(
             settings.RECENTLY_NUM)
         context['hot_posts'] = Post.get_hots_posts(settings.HOT_NUM)
         context['pages'] = Page.objects.filter(status=0)
         if not context.has_key('title'):
             context['title'] = ''
         context['title'] += 'Younfor'
         context['desc'] = 'python,c,c++,java,linux,生活感悟,工作笔记,心情驿站'
         context['keywords'] = 'python,c,c++,java,linux,生活感悟,工作笔记,心情驿站'
         context['author'] = 'younfor'
         context['sitename'] = 'Younfor\'s BLOG'
         context['blogdesc'] = '悄悄是别离的笙箫,所谓爱情,所谓人生,所谓。'
     except Exception as e:
         print e
     return context
开发者ID:Memode,项目名称:django-fly-blog,代码行数:23,代码来源:views.py


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