django 1.3: how to use get_abolute_url in class based generic views
I have following:
===== urls.py ====
from django.conf.urls.defaults import *
from django.views.generic.dates import DateDetailView
from blog.models import Article
entry_info_dict = {
'queryset': Article.objects.all(),
'date_field': 'pub_date',
}
urlpatterns = patterns('django.views.generic.dates',
(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/
$', DateDetailView.as_view(template_name='blog/article_detail.html',
**entry_info_dict)),
)
===== models.py ====
class Article(models.Model):
......
# with django 1.2 was
@models.permalink
def get_absolute_url(self):
return ('article_detail', (), { 'year':
self.pub_date.strftime("%Y"),
'month':
self.pub_date.strftime("%m").lower(),
'day':
self.pub_date.strftime("%d"),
'slug': self.slug })
# how should it look with django 1.3 ??????
And this does not work in template
<ul>
{% for article in object_list %} # ???
<li><h3><a
href="{{ article.get_absolute_url }}">{{ article.title }}</a></h3>
# ????
Posted by {{ article.author }} on {{ article.pub_date|
date:"F jS, Y" }}
</li>
{% endfor %}
</ul>
Please give an example of how to use get_absolute_url within class
based generic views.
--
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