title: filter a query based on a value only if the value is not empty in django
body: <p>I need to filter a query based on a variable but only if this var is not empty ... here is what I have tried :</p>
  <pre class="lang-py prettyprint-override"><code>rows = Attendance.objects.filter(type= the_type if the_type != &quot;&quot; else '*')
  </code></pre>
  <p>the problem is in the part <code>else '*'</code> I have tried to remove else, but it won't work as it is required to use an else after if in the <code>ternary operator</code>, also tried <code>else pass</code> but it gives me an error.</p>
  <h3>Edit</h3>
  <p>I could use <code>if</code> outside of the queryset, but <code>I have more than one dynamic variable that I will use in the same query, so wrapping it inside an if statement won't work well</code>.</p>