questions in sitemap
[prawokultury.git] / questions / sitemap.py
diff --git a/questions/sitemap.py b/questions/sitemap.py
new file mode 100755 (executable)
index 0000000..731cd26
--- /dev/null
@@ -0,0 +1,20 @@
+from django.contrib.sitemaps import Sitemap
+from .models import Question
+
+class QuestionSitemap(Sitemap):
+    changefreq = "never"
+    priority = 0.5
+
+    def items(self):
+        return Question.objects.filter(published=True)
+
+    def lastmod(self, obj):
+        return obj.changed_at
+
+    def location(self, obj):
+        return obj.get_absolute_url()
+
+
+sitemaps = {
+    "question": QuestionSitemap,
+}