title: `SyntaxError: no binding for nonlocal 'topics_with_log_tag' found` although it's bounded
body: <p>I'd like to fetch topics with a specified 'log' tag:</p>
  
  <p>Within the nested function <code>get_topics_with_log_tag</code>, I set variable <code>topics_with_log_tag</code> nonlocal:</p>
  
  <pre><code>def log(request):
      """Show all topics and entries with  log tags"""
  
      topics = Topic.objects.all()
      #select entries with log tag
      def get_topics_with_log_tag(topics):
          nonlocal topics_with_log_tag
          topics_with_log_tag = []
          for topic in topics:
              for entry in topic.entry_set.all():
                  if "#log" in entry.tags:
                      topics_with_log_tag.append(topic)
  
      get_topics_with_log_tag(topics)
  </code></pre>
  
  <p>It throw SyntaxError:</p>
  
  <pre><code>SyntaxError: no binding for nonlocal 'topics_with_log_tag' found
  </code></pre>
  
  <p>Actually, I did bind it <code>topics_with_log_tag = []</code></p>
  
  <p>The above code could be rewrite in a redundant way as </p>
  
  <pre><code>topics = Topic.objects.all()
  #select entries with log tag
  def get_topics_with_log_tag(topics):
      # nonlocal topics_with_log_tag
      topics_with_log_tag = []
      for topic in topics:
          for entry in topic.entry_set.all():
              if "#log" in entry.tags:
                  topics_with_log_tag.append(topic)
      return topics_with_log_tag
  
  topics_with_log_tag = get_topics_with_log_tag(topics)
  </code></pre>
  
  <p>What's the problem with my usage of <code>nonlocal</code>?</p>
  
  <p>I found the error.</p>
  
  <p>Willem Van Onsem introduces database level filter instead of the nested for loop.</p>
  
  <p>The models.py</p>
  
  <pre><code> class Topic(models.Model):
      """A topic the user is learning about."""
      text = models.CharField(max_length=200)
      date_added = models.DateTimeField(auto_now_add=True)
      owner = models.ForeignKey(User)
  
      def __str__(self):
          """Return a string representation of the model."""
          return self.text
  
  class Entry(models.Model):
      """Something specific learned about a topic"""
      topic = models.ForeignKey(Topic)
      title = models.CharField(max_length=200)
      text = models.TextField()
      tags = models.CharField(max_length=200)
      date_added = models.DateTimeField(auto_now_add=True)
  </code></pre>