2013-02-28 13 views
1

我想要做的是從我的WordPress博客中提取標題和URL,並將其顯示爲我的Django模板中的鏈接。將Wordpress Feed拉進Django模板

我發現this example

不過,這並不在Django證明是有用的。 (我是一個n00b)。所以我想知道是否有人對我如何獲取feeb並將其放入Django應用程序有任何建議?

<a href="link-to-feed">Title of blog post</a> 

感謝您提前給予的幫助。

回答

3

基本上你需要在你的Django View中解析你的wordpress feed,然後把渲染的數據發送到你的模板。

Good Resource 也feedparser規格:http://pythonhosted.org/feedparser/

做一些研究,在你的Django視圖與Python解析XML

1. Hit the Wordpress Feed URL in view.py 
2. Parse the resulting XML nodes (or feedparser I think) 
3. Extract needed data 
4. Send data to your django template from the view 
+0

真棒謝謝你的建議! – Modelesq 2013-02-28 22:44:14

0

我知道這個線程是老了,但我發現這是很有益的太: http://geekscrap.com/2010/02/integrate-wordpress-and-django/

我正在使用選項2,xmlrpc。這裏的例子

https://github.com/maxcutler/python-wordpress-xmlrpc/blob/master/docs/examples/posts.rst

這個拉直接從RSS源GitHub的頁面,就像其他的答案。我不知道這個解決方案與另一個解決方案的性能如何,對不起。

+0

真棒,感謝您的帖子! :D – Modelesq 2013-08-01 19:00:08

+0

沒問題!我們現在正在使用它將我們的wordpress.com託管的博客放入我們的常規網站,以便更緊密地控制所有的演示。迄今爲止工作很好。祝你好運! – 2013-08-02 20:03:08