django 1.5的DateDetailView
我正在用django 1.5写一个新的博客,但在我的模板中,我没有与我的entry对象相关的链接 我的模型django 1.5的DateDetailView,django,generics,views,Django,Generics,Views,我正在用django 1.5写一个新的博客,但在我的模板中,我没有与我的entry对象相关的链接 我的模型 def get_absolute_url(self): return reverse('article_archive_date_detail',kwargs = {'year':self.pub_date.strftime("%Y"), 'month':self.pub_date.strftime
def get_absolute_url(self):
return reverse('article_archive_date_detail',kwargs = {'year':self.pub_date.strftime("%Y"),
'month':self.pub_date.strftime("%b").lower(),
'day':self.pub_date.strftime("%d"),
'slug':self.slug})
我的网址:
url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',DateDetailView.as_view(queryset=Article.objects.filter(status=Article.LIVE_STATUS), date_field="pub_date"),name="article_archive_date_detail"),
url(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P[-\w]+)/$,DateDetailView.as_视图(queryset=Article.objects.filter(status=Article.LIVE_status),date_field=“pub_date”),name=“Article_archive_date_detail”),
模板:
{% for entry in latest %}
<a class="readmore" href="{{ entry.get_absolute_url }}">Read more ...</a>
{% endfor %}
{%用于最新%]中的条目
{%endfor%}
我忘记了什么?模板中的
最新的是什么?来自ArchiveIndexView。当您在获取绝对url
中使用kargs
时,它应该是kwargs
。那是邮局的打字错误吗?是的,谢谢。我纠正它