title: Jinja2 'dict object' has no attribute
body: <p>I've been looking at this for hours and I can't figure out what's going on. I'm attempting to set a variable where source is already defined and working elsewhere and then attempting to dive down into the web response to get to alerts. I just need to know if there's alerts so I was hoping to do something to tune of:</p>
  <pre><code>true if alerts else false
  </code></pre>
  <p>Here's the sample mockup of what I'm trying to get data out of:</p>
  <pre class="lang-py prettyprint-override"><code>source = {
      &quot;empty_thing&quot;: [],
      &quot;meta&quot;: {
          &quot;messages&quot;: [
              &quot;RANDOM NUMBER: ABC123&quot;,
          ],
          &quot;transaction&quot;: {
              &quot;final&quot;: true,
              &quot;id&quot;: &quot;ABC123&quot;,
              &quot;timestamp&quot;: &quot;not important&quot;
          },
          &quot;warnings&quot;: []
      },
      &quot;report&quot;: {
          &quot;not_important_thing_1&quot;: [],
          &quot;alerts&quot;: [
              {
                  &quot;information&quot;: &quot;This is information regarding Alert 1.&quot;,
                  &quot;type&quot;: &quot;Alert 1&quot;
              },
              {
                  &quot;information&quot;: &quot;This is information regarding Alert 2.&quot;,
                  &quot;type&quot;: &quot;Alert 2&quot;
              }
          ]
      }
  }
  </code></pre>
  <p>I've tried the following to no avail. I think I'm missing something with how I'm trying to access the alerts but I'm out of ideas.</p>
  <p>I've tried:</p>
  <pre><code>{{ set some_variable = source['report']['alerts'] }} 
  </code></pre>
  <p>I've also tried:</p>
  <pre><code>{{ set some_variable = source.report.alerts }} 
  </code></pre>
  <p>I keep getting the following error with both attempts:</p>
  <pre><code>jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'report'
  </code></pre>
  <p>I'm feeling really stumped at this point and would appreciate some insight into what I might be missing. It could have to do with the data that I'm posting but I won't be able to share that. I just want to make sure I haven't missed something else.</p>
  <p>Thank you!</p>