M
M
maximkalga2016-02-12 16:00:56
Django
maximkalga, 2016-02-12 16:00:56

How to implement sitemap pagination in Django?

The sitemap is generated when you go to the page. Urls are about 700k, everything is very long and hard, the browser crashes.
Is it possible to somehow paginate, for example, 10k?

urls.py
...
from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.contrib.sitemaps.views import sitemap
from ad.models import Offer, OfferArchive, SitemapSearchUrl


info_dict_offer = {
    'queryset': Offer.objects.filter(for_index=True),
    'date_field': 'created',
}

info_dict_archive = {
    'queryset': OfferArchive.objects.all(),
    'date_field': 'created',
}

info_dict_category = {
    'queryset': SitemapSearchUrl.objects.all(),
    'date_field': 'created',
}

sitemaps = {
    'offer': GenericSitemap(info_dict_offer, priority=1),
    'archive': GenericSitemap(info_dict_archive, priority=1),
    'category': GenericSitemap(info_dict_category, priority=1),
}

urlpatterns = [
    ...
    url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
    ...
]

Google answers for one model , but how can you do it for all at once?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-02-12
@sim3x

zen of Py - explicit is better than implicit
models are not often added to the project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question