'How to create sitemap with dynamic sub sitemap structure in django?

I'm trying create a dynamic generate sitemap in django and i hit the wall. Action I'm trying to code:

  • in url.py i have url: re_path(r'sitemap-jobs.xml$'...)
  • the above web address triggers function: MonthlyJobsSitemap in sitemap dict whose create sub sitemap divided by months like: http:/host/sitemap-pl-jobs-2022-01.xml

The result is address in robots.txt sitemap: /sitemap-pl-jobs.xml. After entering there are files splitted on monthly files: /sitemap-pl-jobs.xml-2022-01. And after entering the monthly sitemap i wanna see addresses to jobs published on web site.

I don't have problem with create one sitemap with all jobs but i have to split it into monthly sitemaps.

Someone have any idea how to code that in django?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source