Reputation: 211
I've gone through the process, which is seemingly fairly straightforward of setting up an sitemap.xml file..
I'm getting 404 page when I go to www.example.com/sitemap.xml 'page not found' and a message (I've still got debug settings turned on..) along the lines of:
" Django tried these URL patterns, in this order:
^admin/
^nday/
^ ^$ [name='index']
^ ^tomorrow/$ [name='tomorrow']
^ ^day/(?P<day_name_url>\w+)/$ [name='day']
The current URL, sitemap.xml, didn't match any of these."
This is my urls.py file
from django.conf.urls import patterns, url
from django.contrib.sitemaps.views import sitemap
from nday import views
from nday import sitemap
from nday.sitemap import ndaySitemap
sitemaps = {
'posts': ndaySitemap,
}
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^tomorrow/$', views.tomorrow, name='tomorrow'),
url(r'^day/(?P<day_name_url>\w+)/$', views.day, name='day'),
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),)
and my sitemap.py file..
from django.contrib.sitemaps import Sitemap
from nday import models
from nday.models import nationalday
class ndaySitemap(Sitemap):
changefreq = "daily"
priority = 0.5
def items(self):
return nationalday.objects.all()
I've installed sitemaps as per the settings.py file..
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.sitemaps',
'nday',
)
Thank you so much in advance
Upvotes: 0
Views: 347
Reputation: 308849
If you are using the Django development server, it should reload when you make any code changes.
However in production (e.g. Apache or Nginx) you have to reload the server after making any changes to .py
files.
Upvotes: 1