我有超过 100,000,000 个页面 URL,我怎样才能使 QuerySet 是动态的,因为每个类将有 10,000 个唯一 URL,而无需手动创建 10,000 个类中的整数?
# sitemap.py account_
from django.contrib.sitemaps import Sitemap
from django.shortcuts import reverse
from appname.models import Page
import datetime
from appname.sitemaps import Page000001
from appname.sitemaps import Page000002
ps_dict_01 = {
"ps_file_000001": Page000001,
"ps_file_000002": Page000002,
{
class Page000001(Sitemap):
def items(self):
return Passage.objects.all()[:10000]
lastmod = datetime.datetime.now()
changefreq = 'hourly'
priority = 1.0
protocol = 'http'
class Page000002(Sitemap):
def items(self):
return Passage.objects.all()[10000:20000]
lastmod = datetime.datetime.now()
changefreq = 'hourly'
priority = 1.0
protocol = 'http'