站点地图中的优先级问题 [英] Priority issue in Sitemaps

查看:49
本文介绍了站点地图中的优先级问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Django网站地图.

I am trying to use Django sitemaps.

class BlogSiteMap(Sitemap):
    """A simple class to get sitemaps for blog"""

    changefreq = 'hourly'
    priority = 0.5

    def items(self):
        return Blog.objects.order_by('-pubDate')

    def lastmod(self, obj):
        return obj.pubDate

我的问题是..我想将前三个博客对象的优先级设置为1.0,其余的优先级设置为1.0作为0.5优先级.

My problem is..I wanted to set the priority of first 3 blog object as 1.0 and rest of them as 0.5 priority.

我阅读了文档但没有任何办法.

I read the documentation but couldn't any way out of it.

任何帮助都是可取的.预先感谢.

Any help would be appreciable. Thanks in advance.

推荐答案

我认为您可以更改每个对象的优先级.例如:

I think you can alter each object with its priority. Like that for example:

def items(self):
    for i, obj in enumerate(Blog.objects.order_by('-pubDate')):
       obj.priority = i < 3 and 1 or 0.5
       yield obj

def priority(self, obj):
    return obj.priority

这篇关于站点地图中的优先级问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆