Django 站点地图不返回项目
我创建了一个基本的站点地图。不过我希望让它更符合谷歌的要求。
我有一个可以工作的查询集,但是当我尝试访问自定义模板中的 url.items 时,我只得到默认的“优先级”、lastmod 等...
Sitemaps.py
from django.contrib.sitemaps import Sitemap
from myapp.models import *
class mySitemap(Sitemap):
changefreq = "daily"
priority = 0.5
def items(self):
articles =
sync_Binder.objects.select_related() \
.filter(sync_binder_index__platform_id > = '2') \
.order_by('sync_binder_index__rank')
return articles
def lastmod(self, obj):
return obj.modifieddate
urls.py
sitemaps = {'mysitemap': mySitemap,}
urlpatterns = patterns('django.contrib.sitemaps.views',
(r'^%ssitemap.xml$' % PROJECT_URL, 'sitemap',
{'sitemaps':sitemaps, 'template_name':'sitemap.html'}),
)
sitemap.html 包含以下循环
{% for url in urlset %}
{{ url.items }}
{% endfor %}
...但是我只从包含图像、标题等的文章查询集中获得默认值,
没有任何建议?
谢谢 S
I have a basic sitemap created. However I'm looking to make it more Google compliant.
I have a queryset that works however when I try and access the url.items in my custom template I only get the default 'priority', lastmod etc...
Sitemaps.py
from django.contrib.sitemaps import Sitemap
from myapp.models import *
class mySitemap(Sitemap):
changefreq = "daily"
priority = 0.5
def items(self):
articles =
sync_Binder.objects.select_related() \
.filter(sync_binder_index__platform_id > = '2') \
.order_by('sync_binder_index__rank')
return articles
def lastmod(self, obj):
return obj.modifieddate
urls.py
sitemaps = {'mysitemap': mySitemap,}
urlpatterns = patterns('django.contrib.sitemaps.views',
(r'^%ssitemap.xml
sitemap.html contains the following loop
{% for url in urlset %}
{{ url.items }}
{% endfor %}
...yet I only get the defaults nothing from my articles query set which contains images, headlines etc
Any suggestions?
Thanks
S
% PROJECT_URL, 'sitemap',
{'sitemaps':sitemaps, 'template_name':'sitemap.html'}),
)
sitemap.html contains the following loop
...yet I only get the defaults nothing from my articles query set which contains images, headlines etc
Any suggestions?
Thanks
S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论