I follow the description on the http://docs.djangoproject.com/en/1.2/ref/contrib/sitemaps/
I from django.contrib import sitemaps add this line
(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})
to URLconf
make file sitemap.py with:
from django.contrib.sitemaps import Sitemap
from blog.models import Post
class BlogSitemap(Sitemap):
changefreq = 'monthly'
priority = 0.5
def items(self):
return Post.objects.all()
def lastmod(self, obj):
return obj.date
at this address http://127.0.0.1:8000/sitemap.xml I get an error:
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/sitemaps/views.py" in sitemap
33. maps = sitemaps.values()
Exception Type: AttributeError at /sitemap.xml
Exception Value: 'module' object has no attribute 'values'
Anyone can help me?
You missed a step - look at the example in the documentation.
Instead of importing the sitemaps module in your urls.py, import your BlogSitemap
class, then create a sitemaps dictionary:
sitemaps = {'blog': BlogSitemap}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With