Django如果标记不评估相等性

时间:2012-09-13 15:17:40

标签: python django django-templates django-views

我有一个很大的JSON对象(来自Google Feed API)和一个来自上下文的网址。如果上下文中的URL与供稿条目URL中的相同,则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"}

1 个答案:

答案 0 :(得分:5)

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

需要

{% ifequal aEntry.link my_URL %}