title: Django: Check if value exists in object.filter list
body: <p>In my Django project I need to check whether a user submitted value exists in a list of values that is returned from the database via objects.filter(). </p>
  
  <p>User submitted data:</p>
  
  <pre><code>value = request.data['value_id']
  </code></pre>
  
  <p>Get valid status as ids:</p>
  
  <pre><code>allowed_values = Values.objects.filter(Q(code='Active') | Q(code='Inactive')).values('id')
  </code></pre>
  
  <p>This returns a queryset as follows.</p>
  
  <blockquote>
    <p><code>&lt;QuerySet [{'id': 1}, {'id': 2}]&gt;</code></p>
  </blockquote>
  
  <p>Checking if user submitted value exists in the allowed_values:</p>
  
  <pre><code>if value in allowed_values:
      return True
  </code></pre>
  
  <p>But this does not work and I need allowed_values to return as a list of 'id's. How can I do this without iterating through allowed_values and creating a new list?</p>