[Answered ]-Django NameError urls.py

2👍

Generally you will do something like this –

from django.contrib.sitemaps import Sitemap, FlatPageSitemap

sitemaps = {
  'site': Sitemap,
  'flatpages': FlatPageSitemap,
}

# ..
# Some url patterns. urlpatterns must be defined by now
# ..

urlpatterns += patterns("",
  url(r'^sitemap\.xml$', 
      'django.contrib.sitemaps.views.sitemap', 
      {'sitemaps': sitemaps}
  ),
)

0👍

From the docs:

sitemaps should be a dictionary that maps a short section label (e.g., blog or news) to its Sitemap class (e.g., BlogSitemap or NewsSitemap). It may also map to an instance of a Sitemap class (e.g., BlogSitemap(some_var)).

So… define it.

Leave a comment