Django Information Aggregation

Source: Internet
Author: User

feeds.py

#coding: utf-8__author__ = ' similarface ' from django.contrib.syndication.views import feedfrom Django.template.defaultfilters import truncatewordsfrom. Models import Postclass Lastestpostsfeed (Feed):    title= ' Blog Park '    link= '/myblog '    description= ' new article '    def items ':           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 urlfrom django.contrib import Adminfrom. Import viewsfrom. Feeds import lastestpostsfeedurlpatterns = [    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"?><RSSXmlns:atom= "Http://www.w3.org/2005/Atom"version= "2.0"><Channel><title>Blog Park</title><Link>Http://cnblog.com/myblog</Link><Description>The new article</Description><Atom:linkhref= "http://cnblog.com/myblog/feed/"rel= "Self"></Atom:link><language>Zh_cn</language><lastbuilddate>Wed, APR 2016 04:01:28-0000</lastbuilddate><Item><title>Python code</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 is 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 Operation 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 uploads a directory "" Localfiles = Os.listdir (self.localdir) # listdir is local Li  Sting 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>Format with partition capacity greater than 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 TB encapsulated in LVM with a logical volume of ~ TB on a O Racle 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>Collaborative filtering of data mining</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>Collaborative filtering of data mining</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 Information Aggregation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.