Reputation: 468
My app is throwing ERROR 500 while accessing example.com/sitemap.xml Additional server configurations = Nginx+Gunicorn+postgres
Here are my files
sitemap.py
from django.contrib.sitemaps import Sitemap
from .models import Post, Status
class PostSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9
def items(self):
return Post.objects.filter(status=0)
def lastmod(self, obj):
return obj.created_on
class StatusSitemap(Sitemap):
changefreq='daily'
priority = 0.9
def item(self):
return Status.objects.filter(status=0)
def lastmod(self, obj):
url.py
sitemaps = {
'posts': PostSitemap,
'status': StatusSitemap
}
urlpatterns = [ path('sitemap.xml/', sitemap, {'sitemaps': sitemaps},
name='sitemaps'),]
Don't know why is this showing error 500
Upvotes: 0
Views: 1017
Reputation: 468
Okay In case someone was dumb enough to repeat this silly mistake like me!
Dear, you have forgotten to add 'django.contrib.sitemaps'
, in you INSTALLED APPS.
Upvotes: 2