feeds.py

#coding:utf-8
__author__ = 'similarface' from django.contrib.syndication.views import Feed
from django.template.defaultfilters import truncatewords
from .models import Post class LastestPostsFeed(Feed):
title='博客园'
link='/myblog'
description='新的文章'
def items(self):
return Post.published.order_by('-publish')[:5]
def item_title(self, item):
return item.title
def item_description(self, item):
return truncatewords(item.content, 30)

urls.py

from django.conf.urls import url
from django.contrib import admin
from . import views
from .feeds import LastestPostsFeed urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
#url(r'^$', views.PostListView.as_view(), name='post_list'),
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\w \t]+)/$',views.post_detail,name='post_detail'),
url(r'^(?P<post_id>\d+)/share/$', views.post_share,name='post_share'),
url(r'^tag/(?P<tag_slug>[-\w]+)/$', views.post_list,name='post_list_by_tag'),
url(r'^feed/$', LastestPostsFeed(), name='post_feed'),
]

http://127.0.0.1:8000/myblog/feed/

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>博客园</title><link>http://cnblog.com/myblog</link><description>新的文章</description><atom:link href="http://cnblog.com/myblog/feed/" rel="self"></atom:link><language>zh_CN</language><lastBuildDate>Wed, 20 Apr 2016 04:01:28 -0000</lastBuildDate><item><title>python代码</title><link>http://cnblog.com/myblog/2016/04/20/python%E4%BB%A3%E7%A0%81/</link><description>""" Python Markdown =============== Python Markdown converts Markdown to HTML and can be used as a library or called from the command line. ## Basic usage as a module: import ...</description><guid>http://cnblog.com/myblog/2016/04/20/python%E4%BB%A3%E7%A0%81/</guid></item><item><title>ssss</title><link>http://cnblog.com/myblog/2016/04/19/ssss/</link><description>ssss</description><guid>http://cnblog.com/myblog/2016/04/19/ssss/</guid></item><item><title>python 操作FTP</title><link>http://cnblog.com/myblog/2016/04/19/python%20%E6%93%8D%E4%BD%9CFTP/</link><description>listdir() strips dir path, any failure ends script 上传一个目录 """ localfiles = os.listdir(self.localdir) # listdir is local listing for localname in localfiles: localpath = os.path.join(self.localdir, localname) print('uploading', localpath, 'to', localname, ...</description><guid>http://cnblog.com/myblog/2016/04/19/python%20%E6%93%8D%E4%BD%9CFTP/</guid></item><item><title>分区容量大于16TB的格式化</title><link>http://cnblog.com/myblog/2016/04/19/%E5%88%86%E5%8C%BA%E5%AE%B9%E9%87%8F%E5%A4%A7%E4%BA%8E16TB%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8C%96/</link><description>The demo system My demo system consists of one large LUNof 18 TB encapsulated in LVM with a logical volume of 17 TB on a Oracle Enterprise Linux (OEL 5.5): ...</description><guid>http://cnblog.com/myblog/2016/04/19/%E5%88%86%E5%8C%BA%E5%AE%B9%E9%87%8F%E5%A4%A7%E4%BA%8E16TB%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8C%96/</guid></item><item><title>数据挖掘之协同过滤</title><link>http://cnblog.com/myblog/2016/04/19/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98%E4%B9%8B%E5%8D%8F%E5%90%8C%E8%BF%87%E6%BB%A4/</link><description>数据挖掘之协同过滤</description><guid>http://cnblog.com/myblog/2016/04/19/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98%E4%B9%8B%E5%8D%8F%E5%90%8C%E8%BF%87%E6%BB%A4/</guid></item></channel></rss>

Django之信息聚合的更多相关文章

  1. django中的聚合索引

    Django(元信息)元类建索引 ORM查询(sql优化)优化 自定义聚合函数 Django的元类建索引————索引:索引的一个主要目的就是加快检索表中数据,索引是经过某种算法优化过的,因而查找次数要 ...

  2. 《玩转Django2.0》读书笔记-Django配置信息

    <玩转Django2.0>读书笔记-Django配置信息 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 项目配置是根据实际开发需求从而对整个Web框架编写相应配置信息. ...

  3. Django日志信息路径的设置

    django日志信息路径的设置, 因为我们经常在代码业务上线时候 需要进行调试,查看代码的后台运行情况,就需要设置django项目的具体的日志信息运维的路径了 LOGGING = { 'version ...

  4. ElasticSearch 2 (37) - 信息聚合系列之内存与延时

    ElasticSearch 2 (37) - 信息聚合系列之内存与延时 摘要 控制内存使用与延时 版本 elasticsearch版本: elasticsearch-2.x 内容 Fielddata ...

  5. ElasticSearch 2 (38) - 信息聚合系列之结束与思考

    ElasticSearch 2 (38) - 信息聚合系列之结束与思考 摘要 版本 elasticsearch版本: elasticsearch-2.x 内容 本小节涵盖了许多基本理论以及很多深入的技 ...

  6. ElasticSearch 2 (36) - 信息聚合系列之显著项

    ElasticSearch 2 (36) - 信息聚合系列之显著项 摘要 significant_terms(SigTerms)聚合与其他聚合都不相同.目前为止我们看到的所有聚合在本质上都是简单的数学 ...

  7. ElasticSearch 2 (35) - 信息聚合系列之近似聚合

    ElasticSearch 2 (35) - 信息聚合系列之近似聚合 摘要 如果所有的数据都在一台机器上,那么生活会容易许多,CS201 课商教的经典算法就足够应付这些问题.但如果所有的数据都在一台机 ...

  8. ElasticSearch 2 (34) - 信息聚合系列之多值排序

    ElasticSearch 2 (34) - 信息聚合系列之多值排序 摘要 多值桶(terms.histogram 和 date_histogram)动态生成很多桶,Elasticsearch 是如何 ...

  9. ElasticSearch 2 (33) - 信息聚合系列之聚合过滤

    ElasticSearch 2 (33) - 信息聚合系列之聚合过滤 摘要 聚合范围限定还有一个自然的扩展就是过滤.因为聚合是在查询结果范围内操作的,任何可以适用于查询的过滤器也可以应用在聚合上. 版 ...

随机推荐

  1. 【01】npm/cnpm安装

    包安装相关信息: 1.node_modules文件夹 node_modules文件夹在nodejs中是一个特殊的文件夹,通过它的名字就可以看出,该文件夹也是用于存放node模块.如果一个模块表达式不是 ...

  2. [AGC004E] Salvage Robots (DP)

    Description 蛤蟆国的领土我们可以抽象为H*W的笼子,在这片蛤土上,有若干个机器人和一个出口,其余都是空地,每次蛤蟆会要求让所有的机器人向某个方向移动一步,当机器人移动到出口时会被蛤蟆活摘出 ...

  3. 后缀数组基本问题QAQ

    以下题目均来自罗穗骞的论文... No.1最长公共前缀 最长公共前缀: 题目: 给定一个字符串,询问某两个后缀的最长公共前缀. 分析: 某两个后缀的最长公共前缀就是区间height最小值,转化为RMQ ...

  4. BZOJ 2146 Construct

    Construct [问题描述] 随着改革开放的深入推进…… 小T家要拆迁了…… 当对未来生活充满美好憧憬的小T看到拆迁协议书的时候,小T从一位大好的社会主义青年变成了绝望的钉子户. 由于小T的家位于 ...

  5. ThreadPool学习草稿1

    原文发布时间为:2010-10-27 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Collections.Generic;using Syste ...

  6. FckEditor2.65使用范例源码

    原文发布时间为:2009-10-12 -- 来源于本人的百度文章 [由搬家工具导入] 下载地址:http://www.xmaspx.com/Services/FileAttachment.ashx?A ...

  7. FCKEDITOR配置说明

    原文发布时间为:2009-10-12 -- 来源于本人的百度文章 [由搬家工具导入] fckeditor config.js配置2009-02-13 14:36 FCKConfig.CustomCon ...

  8. C#去除字符串的最后一个字符 与 JavaScript去除最后一个字符

    原文发布时间为:2009-04-29 -- 来源于本人的百度文章 [由搬家工具导入] 例子: C#.NET中去掉字符串的最后一个逗号 字符串为 (a,b,c,)最后一个逗号即c后面的逗号 答: &qu ...

  9. LeetCode OJ-- Add Binary

    https://oj.leetcode.com/problems/add-binary/ 对两个二进制字符串求和. 对于字符串 ans_str,求它的翻转. reverse(ans_str.begin ...

  10. AC日记——[ZJOI2008]树的统计Count bzoj 1036

    1036: [ZJOI2008]树的统计Count Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 15007  Solved: 6092[Submit ...