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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.