Django sitemap index with paged content

I was working on the sitemap index. I would like every 40000 item group into one sitemap on the site index like this

<sitemapindex xmlns="">

I couldn’t find ways of doing it without using plugin.

Each item on the siteindex require it’s own class, so I created class dynamically using type, and by using paginator

from sitemap import generateSitemaps

sitemaps = generateSitemaps()

urlpatterns += patterns('django.contrib.sitemaps.views',
    url(r'^sitemap\.xml$', 'index', {'sitemaps': sitemaps}),
    url(r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', {'sitemaps': sitemaps}),

from models import Post
from django.core.paginator import Paginator


def items(self):
    posts = Post.objects.filter(deletedByAdmin=False, deletedByUser=False).order_by("-id")
    paginator = Paginator(posts, sitemapEntryPage)

def generateSitemaps():
    siteMaps = { "static" : StaticViewSitemap }
    postPages = range(Post.objects.filter(deletedByAdmin=False, deletedByUser=False).count())[0::sitemapEntryPage]
    for postPage in postPages: 
        page = postPage / sitemapEntryPage + 1
        postPageCls = type('postPage' + str(page), (Sitemap,), {'items': items}) = page
        postPageCls.priority = 0.5
        postPageCls.changefreq = 'daily'
        siteMaps['postPage' + str(page)] = postPageCls

    return siteMaps

If there is a better way please feel free to let me know :)

Prince Harry’s naked Las Vegas

Not quite sure what is the fuss is about, if it’s you and me it’s would have been unnoticed anyway…



Well done Team GB

According to this news average £4.5 million investment for each Olympic Medal, individual sports is clearly cheaper than team sports, does it mean we should give up all the team sports? It is wrong to put a price on sports, nevertheless, well done to Team GB!