Commits

Andrés Reyes Monge committed aac9800

- Añadiendo sitemap

Comments (0)

Files changed (3)

armonge_info/settings/settings.py

     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'django.contrib.sitemaps',
     # Uncomment the next line to enable the admin:
     'django.contrib.admin',
     'compressor',

armonge_info/urls.py

 
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
+from blog.sitemaps import BlogSitemap
 from blog.views import PostListView
 
 admin.autodiscover()
 
+sitemaps = {
+    'blog': BlogSitemap()
+}
+
+
 urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
     url(r'^blog/', include('blog.urls')),
     url(r'^markitup/', include('markitup.urls')),
     # Uncomment the next line to enable the admin:
 
+    (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})
 )
+# -*- coding: utf-8 -*-
+
+from django.contrib.sitemaps import Sitemap
+from blog.models import Post
+
+class BlogSitemap(Sitemap):
+    changefreq = "never"
+    priority = 0.5
+
+    def items(self):
+        return Post.objects.filter(public=True)
+
+    def lastmod(self, obj):
+        return obj.date_published