Sunday, September 4, 2011

sitemap

Would You please help me to find a mistake?
--- blog.model.py:
from django.db import models
class Entry(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
is_draft = models.BooleanField()
pub_date = models.DateField()

def __unicode__(self):
return self.title

@models.permalink
def get_absolute_url(self):
return('entry', [str(self.title)])

--- blog.sitemap.py:
from django.contrib.sitemaps import Sitemap

class BlogSitemap(Sitemap):
changefreq = "never"
priority = 0.5
def items(self):
return Entry.objects.filter(is_draft==1)
def lastmod(self, obj):
return obj.pub_date

--- urls.py:
from django.conf.urls.defaults import *
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from testsitemap.blog.models import Entry
from django.contrib import admin
admin.autodiscover()

info_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
}

sitemaps = {
'flatpages': FlatPageSitemap,
'blog': GenericSitemap(info_dict, priority=0.6),
}

urlpatterns = patterns('',
url(r'^entry/(\w+)/$', 'archive',
name='entry
),
url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}),
)

--- blog.views.py:
from django.shortcuts import render_to_response
from testsitemap.blog.models import Entry

def archive(request):
posts = Entry.objects.all()
return render_to_response('archive.html', {'posts': posts })

--- error message:
Request Method: GET
Request URL: http://localhost:8000/sitemap.xml
Django Version: 1.3
Exception Type: NoReverseMatch
Exception Value: Reverse for 'entry' with arguments '('my 1st post',)'
and keyword arguments '{}' not found.
Exception Location: C:\Python26\lib\site-packages\django\core
\urlresolvers.py in reverse, line 337

Thank You very much!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate