Django之信息聚合
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之信息聚合的更多相关文章
- django中的聚合索引
Django(元信息)元类建索引 ORM查询(sql优化)优化 自定义聚合函数 Django的元类建索引————索引:索引的一个主要目的就是加快检索表中数据,索引是经过某种算法优化过的,因而查找次数要 ...
- 《玩转Django2.0》读书笔记-Django配置信息
<玩转Django2.0>读书笔记-Django配置信息 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 项目配置是根据实际开发需求从而对整个Web框架编写相应配置信息. ...
- Django日志信息路径的设置
django日志信息路径的设置, 因为我们经常在代码业务上线时候 需要进行调试,查看代码的后台运行情况,就需要设置django项目的具体的日志信息运维的路径了 LOGGING = { 'version ...
- ElasticSearch 2 (37) - 信息聚合系列之内存与延时
ElasticSearch 2 (37) - 信息聚合系列之内存与延时 摘要 控制内存使用与延时 版本 elasticsearch版本: elasticsearch-2.x 内容 Fielddata ...
- ElasticSearch 2 (38) - 信息聚合系列之结束与思考
ElasticSearch 2 (38) - 信息聚合系列之结束与思考 摘要 版本 elasticsearch版本: elasticsearch-2.x 内容 本小节涵盖了许多基本理论以及很多深入的技 ...
- ElasticSearch 2 (36) - 信息聚合系列之显著项
ElasticSearch 2 (36) - 信息聚合系列之显著项 摘要 significant_terms(SigTerms)聚合与其他聚合都不相同.目前为止我们看到的所有聚合在本质上都是简单的数学 ...
- ElasticSearch 2 (35) - 信息聚合系列之近似聚合
ElasticSearch 2 (35) - 信息聚合系列之近似聚合 摘要 如果所有的数据都在一台机器上,那么生活会容易许多,CS201 课商教的经典算法就足够应付这些问题.但如果所有的数据都在一台机 ...
- ElasticSearch 2 (34) - 信息聚合系列之多值排序
ElasticSearch 2 (34) - 信息聚合系列之多值排序 摘要 多值桶(terms.histogram 和 date_histogram)动态生成很多桶,Elasticsearch 是如何 ...
- ElasticSearch 2 (33) - 信息聚合系列之聚合过滤
ElasticSearch 2 (33) - 信息聚合系列之聚合过滤 摘要 聚合范围限定还有一个自然的扩展就是过滤.因为聚合是在查询结果范围内操作的,任何可以适用于查询的过滤器也可以应用在聚合上. 版 ...
随机推荐
- pat 甲级 Cars on Campus (30)
Cars on Campus (30) 时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard 题目描述 Zhejiang University ...
- 洛谷P2168 荷马史诗
哈夫曼树原理. k=2时,和合并果子一样一样的. 由此思考,k>2时,应该也有相似的原理.确实如此,k进制哈夫曼树,每个结点最多会有k-1个子结点,对应k-1个元素(“元素”可以是更深层的子树) ...
- Javascript&Html-延迟调用和间歇调用
Javascript&Html-延迟调用和间歇调用 Javascript 是一种单线程语言,所有的javascript任务都会放到一个任务列表中,这些javascript任务会按照插入到列表中 ...
- 怎样让enum枚举支持string
原文发布时间为:2011-03-02 -- 来源于本人的百度文章 [由搬家工具导入] 大家都知道enum是以下两种情况,不能支持string 1,enum类型是静态 2,enum类型仅限于long、i ...
- DataGrid关键字变色
原文发布时间为:2009-05-01 -- 来源于本人的百度文章 [由搬家工具导入] private void DataGrid1_ItemDataBound(object sender, ...
- 阿里巴巴Java开发手册公开版(转)
1.不要嫌名字长 无论是方法,变量,还是函数的取名,不要嫌弃名称太长,只要能够表示清楚含义就可以了. 2.String[] args而不是String args[] 中括号是数组类型的一部分,数组定义 ...
- [LeetCode] Unique Binary Search Trees II dfs 深度搜索
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
- eclipse集成JBPM
JBPM4.4是一款运用的比较广泛的工作流开发框架,最近参与的BSS项目里面也有用到了JBPM4.4.自己在已经搭建的框架下使用,但更详细的理解并没有.因此借此机会学习一下. 学习版本为:JBPM为4 ...
- Ubuntu中vim添加lua支持
系统:Ubuntu 15.10/16.04 因为Ubuntu15.10系统自带vim不支持lua,所以得自己编译安装. $ sudo apt install vim-nox vim-nox可以让vim ...
- DOM和jquery对象之间的转换
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...