summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PythonTBC/settings.py1
-rw-r--r--PythonTBC/sitemap.py9
-rw-r--r--PythonTBC/urls.py8
-rw-r--r--tbc/models.py3
4 files changed, 21 insertions, 0 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py
index 0f056d3..2849625 100644
--- a/PythonTBC/settings.py
+++ b/PythonTBC/settings.py
@@ -131,6 +131,7 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'django.contrib.sitemaps',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
diff --git a/PythonTBC/sitemap.py b/PythonTBC/sitemap.py
new file mode 100644
index 0000000..6f70945
--- /dev/null
+++ b/PythonTBC/sitemap.py
@@ -0,0 +1,9 @@
+from django.contrib.sitemaps import Sitemap
+from tbc.models import Chapters
+
+class TbcBookSitemap(Sitemap):
+ changefreq = "never"
+ priority = 0.5
+
+ def items(self):
+ return Chapters.objects.all()
diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py
index d75e545..c5d3753 100644
--- a/PythonTBC/urls.py
+++ b/PythonTBC/urls.py
@@ -4,6 +4,11 @@ from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
+from sitemap import TbcBookSitemap
+sitemaps = {
+ 'book': TbcBookSitemap,
+}
+
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'PythonTBC.views.home', name='home'),
@@ -16,4 +21,7 @@ urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^comments/', include('comments.urls')),
url(r'^', include('tbc.urls', namespace='tbc')),
+ url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
)
+
+
diff --git a/tbc/models.py b/tbc/models.py
index 74419e4..960683d 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -104,6 +104,7 @@ class Book(models.Model):
def __unicode__(self):
name = self.title or 'Book'
return '%s'%(name)
+
class Chapters(models.Model):
name = models.CharField(max_length=200)
@@ -113,6 +114,8 @@ class Chapters(models.Model):
def __unicode__(self):
name = self.name or 'Chapter'
return '%s'%(name)
+ def get_absolute_url(self):
+ return self.notebook
class ScreenShots(models.Model):