Django Sitemaps не показывает мои посты - PullRequest
0 голосов
/ 11 мая 2018

Я использую Django Sitemap Framework.

Вы можете посмотреть мою карту сайта здесь:

https://dealmazing.com/sitemap.xml

Кажется, что мой блог поднимается на /blog

но не мои настоящие сообщения в блоге. похоже, что он записывает фактические сообщения снова и снова как dealmazing.com/blog, но без реального URL

Это мой файл sitemaps.xml

from django.contrib import sitemaps
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
from deals.models import Deal, Category, Retailer
from blog.models import Post, BlogCategory

class StaticViewSitemap(sitemaps.Sitemap):
    priority = 1.0
    changefreq = 'daily'

    def items(self):
        return ['about', 'contact', 'disclosure', 'terms', 'privacy', 'deals:deals', 'blog:blog']

    def location(self,item):
        return reverse(item)


class BlogSitemap(Sitemap):
    changfreq = "daily"
    priority = 1.0
    location ='/blog'

    def items(self):
        return Post.objects.filter(status='Published')

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

class BlogCategorySitemap(Sitemap):
    changfreq = "daily"
    priority = 1.0

    def items(self):
        return BlogCategory.objects.all()

class DealCategorySitemap(Sitemap):
    changfreq = "daily"
    priority = 1.0

    def items(self):
        return Category.objects.all()

class RetailerSitemap(Sitemap):
    changfreq = "daily"
    priority = 1.0

    def items(self):
        return Retailer.objects.all()


class DealSitemap(Sitemap):
    changfreq = "daily"
    priority = 1.0

    def items(self):
        return Deal.objects.all()

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

и в моем файле URL

sitemaps = {
    'static': StaticViewSitemap,
    'blog': BlogSitemap,
    'blog-category': BlogCategorySitemap,
    'deals': DealSitemap,
    'deals-category': DealCategorySitemap,
    'retailers': RetailerSitemap
}

 path('sitemap.xml', sitemap,
         {'sitemaps': sitemaps},
         name='django.contrib.sitemaps.views.sitemap'),

Я не могу точно определить, почему он не публикует полный URL

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...