Skip to main content

No project description provided

Project description

sitemap.xml generation using lxml with support for alternates.

Usage

from app.pages.sitemaps import PagesSitemap

def sitemap(request):
    sitemap = Sitemap(build_absolute_uri=request.build_absolute_uri)
    sitemap.add_django_sitemap(request, PagesSitemap)

    for p in Page.objects.active():
        url = p.get_absolute_url()
        sitemap.add(
            url,
            changefreq='weekly',
            priority=0.5,
            lastmod=p.modification_date,
            alternates={
                code: urljoin(domain, url)
                for code, domain in PAGE_DOMAINS[p.language].items()
            },
        )

    return sitemap.response(pretty_print=settings.DEBUG)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sitemaps-1.0.tar.gz (3.7 kB view hashes)

Uploaded source

Built Distribution

django_sitemaps-1.0-py2.py3-none-any.whl (4.3 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page