You forget the decorator: @models.permalink def get_absolute_url(self): return ('blog_post_detail', None, { 'year': self.publish.year, 'month': self.publish.strftime('%b').lower(), 'day': self.publish.day, 'slug': self.slug })
2011/11/15 Fredrik Grahn <fredrik__gr...@hotmail.com> > Hello, > I'm trying to get my head around some of the basics of Django and I've > run into the strangest problem. Can't figure out what the problem is, > the URL from my get_absolute_url() function in my model just refuses > to turn into a proper URL. I'll post the code so hopefully it will be > obvious for someone with more experience. > > My url : > url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<slug>[-\w] > +)/$', > PostDetailView.as_view(), > name='blog_post_detail' > ), > > My generic view: > class PostDetailView(DetailView): > queryset = Post.objects.filter(status__gte=2) > context_object_name = 'post_detail' > template_name = 'blog/post_detail.html' > > and finally, the get_absolute_url() function in my model. > > def get_absolute_url(self): > return ('blog_post_detail', None, { > 'year': self.publish.year, > 'month': self.publish.strftime('%b').lower(), > 'day': self.publish.day, > 'slug': self.slug > }) > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.