Opened 5 years ago

Closed 4 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

Description

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. http://github.com/palewire/django-sitemaps-index-bug

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 5 years ago.
Add optional kwarg for 'section_urlname'

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by palewire

Add optional kwarg for 'section_urlname'

comment:1 Changed 5 years ago by palewire

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.1 to SVN

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 5 years ago by mlavin

  • Needs documentation set
  • Needs tests set
  • Owner changed from nobody to mlavin
  • Status changed from new to assigned

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: http://www.sitemaps.org/protocol.php#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 5 years ago by mlavin

  • Owner changed from mlavin to nobody
  • Status changed from assigned to new
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 4 years ago by gabrielhurley

  • Component changed from Contrib apps to contrib.sitemaps

comment:5 Changed 4 years ago by graham_king

  • Severity set to Normal
  • Type set to Bug

comment:6 Changed 4 years ago by jezdez

  • Easy pickings unset
  • UI/UX unset

Duplicate of #2713.

comment:7 Changed 4 years ago by jezdez

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top