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) - 信息聚合系列之聚合过滤 摘要 聚合范围限定还有一个自然的扩展就是过滤.因为聚合是在查询结果范围内操作的,任何可以适用于查询的过滤器也可以应用在聚合上. 版 ...
随机推荐
- 【HDOJ5533】Dancing Stars on Me(计算几何)
题意:给定二维平面上的n个整点,问它们是否都在正n边形的定点上 n<=100,abs(x[i]),abs(y[i])<=1e4 思路:队友做的,抱大腿 可以发现只有n=4时顶点有可能都是整 ...
- echarts源码中关于 判断平台的有用代码
function detect(ua) { var os = {}; var browser = {}; // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\ ...
- [LeetCode] Compare Version Numbers 字符串操作
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...
- Spring Boot学习——AOP编程的简单实现
首先应该明白一点,AOP是一种编程范式,是一种程序设计思想,与具体的计算机编程语言无关,所以不止是Java,像.Net等其他编程语言也有AOP的实现方式.AOP的思想理念就是将通用逻辑从业务逻辑中分离 ...
- Syslog协议日志格式翻译
通用日志格式规范(参考 RFC5424 Syslog协议) 下面是RFC5424 Syslog协议关于信息格式的定义. Syslog信息的格式定义 # 一条信息的构成 SYSLOG-MSG = HEA ...
- jquery的toggle动画效果显示隐藏
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- DB2数据库报 [SQL0805N Package "NULLID.SQLLD003" was not found.]
解决办法: cd /home/db2inst1/sqllib/bnddb2 bind @db2cli.lst blocking all grant public sqlerror continue C ...
- HDU 4866 Shooting (主席树)
题目链接 HDU 4866 题意 给定$n$条线段.每条线段平行$x$轴,离x轴的距离为$D$,覆盖的坐标范围为$[L, R]$. 现在有$m$次射击行动,每一次的射击行动可以描述为在横坐标$ ...
- Codeforces 777E Hanoi Factory(线段树维护DP)
题目链接 Hanoi Factory 很容易想到这是一个DAG模型,那么状态转移方程就出来了. 但是排序的时候有个小细节:b相同时看a的值. 因为按照惯例,堆塔的时候肯定是内半径大的在下面. 因为N有 ...
- ActiveMQ 权限(二)
在 ActiveMQ 权限(一) 配置了对消息队列的权限,以下设置完成消息的权限,比如只接受某ip的消息. 两步完成, 第一步:继承接口org.apache.activemq.security.Mes ...