phodal / growth-in-action

全栈增长工程师实战

Home Page:http://growth-in-action.phodal.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chapter4创建`sitemap.xml`模版问题

OswaldoBornemann opened this issue · comments

我想问下 具体的这个sitemap.xml应该放在哪个文件夹下面?

然后要怎么才能够让它产生作用?

我试了三四个小时都不知道。。

sitemap.xml 要放在 templates目录下

那我觉得可能在urls.py里面应该要这样写
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps, 'template_name': 'sitemap.xml'}, name='django.contrib.sitemaps.views.sitemap'),

就是要指明template_name吧?

@tsungruihon �最近比较忙,忘回了。它的name决定了view来自于django.contrib.sitemaps.views.sitemap,在这其中指定了 sitemap.xml 的位置。

def sitemap(request, sitemaps, section=None,
            template_name='sitemap.xml', content_type='application/xml'):

不过,我应该在内容里面详细说明一下。

Thanks