Python 创建了一个网站地图,但谷歌无法';t取数错误

Python 创建了一个网站地图,但谷歌无法';t取数错误,python,django,sitemap,google-search-console,Python,Django,Sitemap,Google Search Console,在Django,我为我的项目创建了一个站点地图。我没有使用内置的django站点地图框架。我创建了一个视图和模板,并从url.py指向它。当我在explorer中打开它时,sitemap工作正常。但当我将我的站点地图添加到searh控制台时,google give me无法获取错误 我想不出是什么问题。有什么想法吗 我的看法是: class SitemapPost(ListView): model = Movies ordering = ['-pk'] template

在Django,我为我的项目创建了一个站点地图。我没有使用内置的django站点地图框架。我创建了一个视图和模板,并从url.py指向它。当我在explorer中打开它时,sitemap工作正常。但当我将我的站点地图添加到searh控制台时,google give me无法获取错误

我想不出是什么问题。有什么想法吗

我的看法是:

class SitemapPost(ListView):

    model = Movies
    ordering = ['-pk']
    template_name = "front/sitemap-post.xml"
    content_type='application/xml'


    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        today = datetime.now()
        context['today'] = datetime.now()
        return context
网址:

模板:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {% for object in object_list %}
  <url>
    <loc>https://{{request.get_host}}{{ object.get_absolute_url }}</loc>
    <lastmod>{{today|date:"Y-m-d"}}</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>
{% endfor %}
</urlset>

为什么不使用django站点地图框架呢?非常好。无论如何,请尝试将其添加到您的
robots.txt
文件中

Sitemap: linkToSitemap

User-agent: Googlebot
Disallow:

User-agent: AdsBot-Google
Disallow:

User-agent: Googlebot-Image
Disallow:
这使得谷歌能够抓取你的网站,因为一些服务器会自动阻止它。如果还没有,请确保将其添加到URL中

path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),),
解决**

我更改了域名,然后再试一次。成功了。
我认为这是搜索控制台的一个缺陷。

django sitemap框架也存在同样的问题。我也有一个类似的robots.txt。我的其他页面都被编入了索引。我的sitemap.xml文件也被谷歌编入了索引。但无法将其添加为站点地图。
Sitemap: linkToSitemap

User-agent: Googlebot
Disallow:

User-agent: AdsBot-Google
Disallow:

User-agent: Googlebot-Image
Disallow:
path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),),