Opened 10 years ago

Closed 9 years ago

#13908 closed Bug (duplicate)

contrib.sitemaps.view.index doesn't work in more than one location

Reported by: palewire Owned by: nobody
Component: contrib.sitemaps Version: master
Severity: Normal Keywords: sitemaps index pagination xml
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


The sitemaps app doesn't seem to allow "index" sitemaps with pagination in more than one location. For instance, if two different apps try to create an index site at two different urls, one set of urls will overwrite the other. I've created a demonstration app that shows the problem on Github. You can find it here.

Maybe it's a dumb idea to have two different sitemaps like that, but I'm not sure it's the intention of the app to act that way. If there's a way to override things and sort it out, allow me to apologize in advance.

Attachments (1)

patch.diff (1.0 KB) - added by palewire 10 years ago.
Add optional kwarg for 'section_urlname'

Download all attachments as: .zip

Change History (8)

Changed 10 years ago by palewire

Attachment: patch.diff added

Add optional kwarg for 'section_urlname'

comment:1 Changed 10 years ago by palewire

Has patch: set
Version: 1.1SVN

I just added a patch that adds and optional kwarg where you can override the urlname that the view now reverses by default. So, if you wanted to use multiple index+section combinations across your site, you could pull it off by adding that kwarg to your index url. Like so:

from app1.sitemaps import FakeSitemap
from django.conf.urls.defaults import *

# Sitemaps
sitemaps = {
    'fake': FakeSitemap,

urlpatterns = patterns('django.contrib.sitemaps.views',
    url(r'^sitemap\.xml$', 'index', {
        'sitemaps': sitemaps,
        'section_urlname': 'app1-sitemap-section',
        }, name='app1-sitemap'),

    url(r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', {
        'sitemaps': sitemaps
        }, name='app1-sitemap-section'),

comment:2 Changed 10 years ago by Mark Lavin

Needs documentation: set
Needs tests: set
Owner: changed from nobody to Mark Lavin
Status: newassigned

I have verified the issue (using [13713]) from the sample project . I would say this is a valid bug as the sitemaps specification clearly states that you can have more than one sitemap index:

If you do provide multiple Sitemaps, you should then list each Sitemap file in a Sitemap index file. 
Sitemap index files may not list more than 50,000 Sitemaps and must be no larger than 10MB (10,485,760 bytes) and can be compressed. 
You can have more than one Sitemap index file. The XML format of a Sitemap index file is very similar to the XML format of a Sitemap file.

However this patch needs some work. There are no tests and the new keyword argument is undocumented.

comment:3 Changed 10 years ago by Mark Lavin

Owner: changed from Mark Lavin to nobody
Status: assignednew
Triage Stage: UnreviewedAccepted

comment:4 Changed 9 years ago by Gabriel Hurley

Component: Contrib appscontrib.sitemaps

comment:5 Changed 9 years ago by Graham King

Severity: Normal
Type: Bug

comment:6 Changed 9 years ago by Jannis Leidel

Easy pickings: unset
UI/UX: unset

Duplicate of #2713.

comment:7 Changed 9 years ago by Jannis Leidel

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top