Ticket #2713: 2713.diff

File 2713.diff, 1.9 KB (added by Chris Beaven, 15 years ago)
  • django/contrib/sitemaps/views.py

    ### Eclipse Workspace Patch 1.0
    #P Django trunk
     
    55from django.utils.encoding import smart_str
    66from django.core.paginator import EmptyPage, PageNotAnInteger
    77
    8 def index(request, sitemaps):
     8def index(request, sitemaps, sitemap_url_name=None):
    99    current_site = Site.objects.get_current()
    1010    sites = []
    1111    protocol = request.is_secure() and 'https' or 'http'
     
    1414            pages = site().paginator.num_pages
    1515        else:
    1616            pages = site.paginator.num_pages
    17         sitemap_url = urlresolvers.reverse('django.contrib.sitemaps.views.sitemap', kwargs={'section': section})
     17        sitemap_url_name = sitemap_url_name or 'django.contrib.sitemaps.views.sitemap'
     18        sitemap_url = urlresolvers.reverse(sitemap_url_name, kwargs={'section': section})
    1819        sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url))
    1920        if pages > 1:
    2021            for page in range(2, pages+1):
  • docs/ref/contrib/sitemaps.txt

     
    292292URLs. In this case, Django will automatically paginate the sitemap, and the
    293293index will reflect that.
    294294
     295If you are not using the vanilla sitemap view (for example, if it is wrapped
     296with a caching decorator), name your sitemap view and pass ``sitemap_url_name``
     297to the index view::
     298
     299   url(r'^sitemap.xml$', sitemap_views.index,
     300       {'sitemaps': sitemaps, 'sitemap_url_name': 'sitemaps'}),
     301   url(r'^sitemap-(?P<section>.+)\.xml$', cache_page(sitemap_views.sitemap, 86400),
     302       {'sitemaps': sitemaps}, name='sitemaps'), 
     303
    295304Pinging Google
    296305==============
    297306
Back to Top