我跟隨在http://docs.djangoproject.com/en/1.2/ref/contrib/sitemaps/Django的網站地圖:「模塊」對象沒有屬性「值」
描述我從django.contrib中導入站點地圖此行添加
(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})
到URL配置
使文件sitemap.py與:
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
在此地址http://127.0.0.1:8000/sitemap.xml我收到一個錯誤:
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'
任何人都可以幫助我嗎?
/views.py評論地圖= sitemaps.values()和打印目錄(網站地圖)...告訴我們它顯示了什麼。 – panchicore 2011-02-14 19:26:04
['FlatPageSitemap','GenericSitemap','錯誤配置','PING_URL','Site','Sitemap','SitemapNotFound','__builtins__','__doc__','__file__','__name__','__package__', '__path__','get_current_site','models','paginator','ping_google','urllib','urlresolvers','views'] – 2011-02-14 19:45:38