Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing list in dictionary of django template
    primarykey
    data
    text
    <p>Hi I have a Django template tag to get an rss feed. It is quite simple and uses feedparser to place the decoded result in the context. IE</p> <pre><code>context[self.var_name] = feedparser.parse(self.url) </code></pre> <p>For a particular url '<a href="http://feeds.bbci.co.uk/news/england/oxford/rss.xml" rel="nofollow">http://feeds.bbci.co.uk/news/england/oxford/rss.xml</a>' The first entry printed from feedparser has an entry like this (I have removed other keys to keep this post short).</p> <pre><code>{'media_thumbnail': [{'url': u'_67862157_67862150.jpg', 'width': u'66', 'height': u'49'}, {'url': u'67862000/jpg/_67862158_67862150.jpg', 'width': u'144', 'height': u'81'}]} </code></pre> <p>However, in my template tag test the element 'media_thumbnail' is changed so the list is empty.</p> <p>My test case</p> <pre><code>class GetRssTagTest(TestCase): def test_request(self): t = Template('{% load rss_parser %}}{% get_rss "feed.xml" as rss %}{{rss.entries.0}}') c = Context({}) print t.render(c) </code></pre> <p>returns</p> <pre><code>{media_thumbnail&amp;#39;: u&amp;#39;&amp;#39;} </code></pre> <p>(Again have removed other fields)</p> <p>I can't understand why is element has been removed ? There are other lists in that dictionary that have been left.</p> <p>Is there some kind of key/size limit to what can be passed to a context variable ?</p> <p>I know I could make a tag custom and do this in Python but I would rather keep the tag generic for use with other feeds.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload