Im getting a name error: name sitemaps is not defined
from my urls.py when I try to integrate sitemaps with my application.
From my urls.py:
from django.contrib.sitemaps import Sitemap
(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
Is there something wrong with this regular expression from my urls.py? Or is there another problem going on?
Thanks for your input
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}
),
)
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.