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


Python Tag.all方法代码示例

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


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

示例1: GET

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
    def GET(self,tags=None):
        urls = []
        def addurl(loc,lastmod=None,changefreq=None,priority=None):
            url_info = {
                'location':   loc,
                'lastmod':    lastmod,
                'changefreq': changefreq,
                'priority':   priority
            }
            urls.append(url_info)

        addurl(self.blog.baseurl,changefreq='daily',priority=0.9 )

        entries = Entry.all().filter(published = True).order_by('-date')[0:self.blog.sitemap_entries]#.fetch(self.blog.sitemap_entries)

        for item in entries:
            loc = "%s/%s" % (self.blog.baseurl, item.link)
            addurl(loc,item.mod_date or item.date,'never',0.6)

        if self.blog.sitemap_include_category:
            cats=Category.all()
            for cat in cats:
                loc="%s/category/%s"%(self.blog.baseurl,cat.slug)
                addurl(loc,None,'weekly',0.5)

        if self.blog.sitemap_include_tag:
            tags=Tag.all()
            for tag in tags:
                loc="%s/tag/%s"%(self.blog.baseurl, urlencode(tag.tag))
                addurl(loc,None,'weekly',0.5)


##        self.response.headers['Content-Type'] = 'application/atom+xml'
        self.render('/admin/views/sitemap.xml', {'urlset':urls}, content_type='text/xml')#, content_type='application/xhtml+xml')
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:36,代码来源:views.py

示例2: admin_edit_post

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def admin_edit_post(request, post_id):
    
    if users.is_current_user_admin():
        
        post = Post.get_by_id(int(post_id))
        if not post:
            raise Http404
        
        if request.method == 'GET':
            tp = Tag_Post.all().filter('post', post)
            
            tags = ''
            # Get all tags
            for tag in tp:
                tags += tag.tag.title + ','
                
            form = PostForm({'title':post.title, 'category':post.category.key(), 'content':post.content, 'tags':tags})
            
        elif request.method == 'POST':
            
            form = PostForm(request.POST)
            
            if form.is_valid():
                
                # delete related tag_post
                for tp in post.tags:
                    tp.delete()

                p = form.save(commit=False)
                post.author = users.get_current_user()
                post.category = p.category
                post.content = p.content
                post.put()

                # add tag_post
                tagText = request.POST['tags']
                if tagText:
                    tags = tagText.split(',')
                    for tag in tags:
                        if tag:
                            tag = string.lower(string.strip(tag))

                            t = Tag.all().filter("title = ", unicode(tag, "utf-8")).get()
                            if not t:

                                t = Tag(title=unicode(tag, "utf-8"))
                                t.put()
                            Tag_Post(tag=t, post=post).put()

            return HttpResponseRedirect('/admin')
        
        return render_to_response('admin/edit.html',
                                      dictionary={ 'form':form,
                                                    'type': 'Edit Post',
                                                     },
                                      context_instance=RequestContext(request)
                                    )
    else:
        return HttpResponseRedirect('/')
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:61,代码来源:admin_views.py

示例3: action_update_tags

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
    def action_update_tags(self,slug=None):
        for tag in Tag.all():
            tag.delete()
        for entry in Entry.all().filter('entrytype =','post'):
            if entry.tags:
                for t in entry.tags:
                    try:
                        Tag.add(t)
                    except:
                        traceback.print_exc()

        self.write(_('"All tags for entry have been updated."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:14,代码来源:views.py

示例4: clean_gae

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def clean_gae():
   query = Entry.all()
   entries =query.fetch(1000)
   db.delete(entries)

   query = Country.all()
   countries = query.fetch(1000)
   db.delete(countries)

   query = Tag.all()
   tags = query.fetch(1000)
   db.delete(tags)
开发者ID:kelvinn,项目名称:gae-demo-blog,代码行数:14,代码来源:myhelpers.py

示例5: admin_list_tag

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def admin_list_tag(request):
    if users.is_current_user_admin():
        
        return object_list(request,
                       template_object_name='obj',
                       queryset=Tag.all(),
                       allow_empty=True,
                       extra_context={'type': 'tag'},
                       template_name='admin/list.html',
                       paginate_by=setting.ADMIN_LIST_PER_PAGE,
                       )
    else:
        return HttpResponseRedirect('/')
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:15,代码来源:admin_views.py

示例6: initialize

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
 def initialize(self, request):
     m_pages=Entry.all().filter('entrytype =','page')\
         .filter('published =',True)\
         .filter('entry_parent =',0)\
         .order('menu_order')
     blogroll=Link.all().filter('linktype =','blogroll')
     archives=Archive.all().order('-year').order('-month').fetch(12)
     alltags=Tag.all()
     self.template_vals.update({
                     'menu_pages':m_pages,
                     'categories':Category.all(),
                     'blogroll':blogroll,
                     'archives':archives,
                     'alltags':alltags,
                     'recent_comments':Comment.all().order('-date').fetch(5)
     })
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:18,代码来源:views.py

示例7: admin_add_post

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def admin_add_post(request):

    if users.is_current_user_admin():
        if request.method == 'GET':
            form = PostForm()
            
        elif request.method == 'POST':
            form = PostForm(request.POST)
            
            if form.is_valid():
                post = form.save(commit=False)
                post.author = users.get_current_user()
                post.put()
                
                tagText = request.POST['tags']
                tags = tagText.split(',')
                for tag in tags:
                    if tag:
                        tag = string.lower(string.strip(tag))
                        
                        t = Tag.all().filter("title = ", unicode(tag, "utf-8")).get()
                        if not t:
                            t = Tag(title=unicode(tag, "utf-8"))
                            t.put()
                        Tag_Post(tag=t, post=post).put()

                return HttpResponseRedirect('/admin')

        return render_to_response('admin/edit.html',
                                        dictionary={ 'form':form ,
                                                         'type': 'Add Post',
                                                     },
                                      context_instance=RequestContext(request)
                                    )
    else:
        return HttpResponseRedirect('/')
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:38,代码来源:admin_views.py

示例8: widgets

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def widgets(context):
    context['categories'] = Category.all()
    context['tags'] = Tag.all()
    context['archives'] = Post.getArchives()
    context['settings'] = UserSettings.getByCurrentUser()
    return context
开发者ID:lvbeck,项目名称:niubi,代码行数:8,代码来源:widgets.py

示例9: GenericSitemap

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.conf.urls.defaults import *
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from blog.models import Post, Category, Tag
from feeds.models import LatestEntries, HottestEntries

feeds = {"latest": LatestEntries, "hottest": HottestEntries}

posts = {"queryset": Post.all().filter("is_published", True), "date_field": "create_time"}

tags = {"queryset": Tag.all().order("-post_count")}

categories = {"queryset": Category.all().order("-post_count")}

sitemaps = {
    "flatpages": FlatPageSitemap,
    "blog": GenericSitemap(posts, priority=0.6, changefreq="monthly"),
    #'tag': GenericSitemap(tags, priority=0.5, changefreq='monthly'),
    #'category': GenericSitemap(categories, priority=0.4, changefreq='yearly'),
}

urlpatterns = patterns(
    "",
    (r"^$", "blog.views.list_post"),
    (r"update/$", "blog.views.update"),
    (r"^about/$", "blog.views.about"),
开发者ID:lvbeck,项目名称:niubi,代码行数:33,代码来源:urls.py

示例10: GenericSitemap

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from blog.models import Post, Category, Tag
from feeds.models import LatestEntries, HottestEntries

feeds = {
    'latest': LatestEntries,
    'hottest': HottestEntries,
}

posts = {
    'queryset': Post.all().filter('is_published', True),
    'date_field': 'create_time',
}

tags = {
    'queryset': Tag.all().order('-post_count'),
}

categories = {
    'queryset': Category.all().order('-post_count'),
}

sitemaps = {
    'flatpages': FlatPageSitemap,
    'blog': GenericSitemap(posts, priority=0.6, changefreq='monthly'),
    #'tag': GenericSitemap(tags, priority=0.5, changefreq='monthly'),
    #'category': GenericSitemap(categories, priority=0.4, changefreq='yearly'),   
}

urlpatterns = patterns('',
    (r'^$', 'blog.views.list_post'),
开发者ID:ytrstu,项目名称:niubi,代码行数:33,代码来源:urls.py

示例11: wwb_list_tag_cloud

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def wwb_list_tag_cloud():   
    html = ''
    for tag in Tag.all():
        html += ''
    return html
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:7,代码来源:wwb_fun.py

示例12: wwb_list_tag

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
def wwb_list_tag():   
    html = ''
    for tag in Tag.all():
        html += '<li><a href=\"%s">%s</a></li>'%(tag.get_absolute_url(), tag.title.encode('utf-8'))
    return html
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:7,代码来源:wwb_fun.py

示例13: items

# 需要导入模块: from blog.models import Tag [as 别名]
# 或者: from blog.models.Tag import all [as 别名]
 def items(self):
     return Tag.all()
开发者ID:raychorn,项目名称:DjangoSample1,代码行数:4,代码来源:sitemaps.py


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