1 from django.contrib.sitemaps import Sitemap
2 from forum.models import Question
3 from django.conf import settings
5 class QuestionsSitemap(Sitemap):
9 return Question.objects.filter_state(deleted=False)
11 def lastmod(self, obj):
12 return obj.last_activity_at
14 def location(self, obj):
15 return obj.get_absolute_url()
17 def __get(self, name, obj, default=None):
19 attr = getattr(self, name)
20 except AttributeError:
26 def get_urls(self, page=1):
28 for item in self.paginator.page(page).object_list:
29 loc = "%s%s" % (settings.APP_URL, self.__get('location', item))
32 'lastmod': self.__get('lastmod', item, None),
33 'changefreq': self.__get('changefreq', item, None),
34 'priority': self.__get('priority', item, None)