2012-09-13 67 views
1

我有一個很大的JSON對象(來自Google Feed API)和一個來自上下文的URL。當上下文的URL與提要條目URL相同時,django應解析!Django如果標籤沒有評估相等性

{for aEntry in feed.entries %} 
{% if aEntry.link == {{my_URL}} %} 

<p>URL FOUND in feed entry</p> 
{% endif %} 
{% endfor %} 

這不工作!

編輯:

feed: { 
      "feedUrl": "http://.blogspot.in//feeds/posts/default", 
      "title": "", 
      "link": "http://.blogspot.com/", 
      "author": "", 
      "description": "", 
      "type": "atom10", 
      "entries": [{ 
       "title": "Shades", 
       "link": "http://.blogspot.com/myurl.html", 
       "author": "", 
       "publishedDate": "Sun, 29 Jul 2012 04:07:00 -0700", 
       "contentSnippet": "abstract art!", 
       "content": " HTML CONTENT HERE", 
       "categories": ["abstract"] 
      } 

context = { "feed" : feed, "my_url" : "http://.blogspot.com/myurl.html"} 
+0

「aEntry.link」 是一個字符串 – anhtran

+0

@anhtran是啊,所以做'{{my_URL}}' –

+0

@anhtran oops。它在這個問題上的錯誤..糾正! –

回答

5
{% if "aEntry.link" == {{my_URL}} %} 

需求是

{% ifequal aEntry.link my_URL %} 
+0

它不起作用。其實這是我的問題中的一個小錯字! –

+0

{{my_URL}}還需要鬆開括號 – JamesO

+0

抱歉..剛剛更新。答案 – karthikr