#2713: Sitemap Index with Cache gives a NoReverseMatch exception
--------------------------+-------------------------------------------------
Reporter: JayKlehr | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Contrib apps | Version: SVN
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
I posted this in the Google Groups ( http://groups.google.com/group/
django-users/browse_thread/thread/fc88c493b16623f/28bfe98a7b4f98c5 ) list
but didn't get a response so I thought I'd create a ticket for it since it
does seem like a bug to me.
Following the djangoproject.com Sitemap example (
source:djangoproject.com/django_website/urls.py ) and the documentation on
Sitemaps ( http://www.djangoproject.com/documentation/sitemaps/ ) I'm
trying to implement a caching Sitemap Index that will link out to other
Sitemaps for my site (one for each main model basically). I had the
Sitemap Index working with the separate sitemaps just fine until I decided
I wanted to add caching in my urls.py (I am using the djangoproject.com
urls.py as an example.)
Here's some snippets...
{{{
#!python
from django.conf.urls.defaults import *
from django.contrib.sitemaps import views as sitemap_views
from django.views.decorators.cache import cache_page
urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^sitemap.xml$', cache_page(sitemap_views.index, 60 * 60 * 24),
{'sitemaps': my_sitemaps}),
(r'^sitemap-(?P<section>.+).xml$', cache_page(sitemap_views.sitemap,
60 * 60 * 24), {'sitemaps': my_sitemaps}),
)
}}}
my_sitemaps is a dictionary of my sitemaps (built following the example in
the Sitemap documentation). With this code I can access the individual
sitemaps without trouble, but can't access the main sitemap.xml file
(that's when I get the "!NoReverseMatch at /sitemap.xml"
exception). However, the following code worked for all files:
{{{
#!python
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps':
my_sitemaps}),
(r'^sitemap-(?P<section>.+).xml$',
'django.contrib.sitemaps.views.sitemap, {'sitemaps': my_sitemaps}),
)
}}}
But I can't implement the cache using this method because you can't pass
the string 'django.contrib.sitemaps.views.index' as the first parameter of
cache_page since it's expecting a callable.
--
Ticket URL: <http://code.djangoproject.com/ticket/2713>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---