title: Where to define a QuerySet in Django
body: <p>I want to define a queryset. In the shell it is all fine and I can filter the column I want with:</p>
  
  <pre><code>pat1 = Patient.objects.get(pk=1)
  pat1.examinationgeometry_set.filter(examination='FIRST')
  </code></pre>
  
  <p>now I want to define a QuerySet out of it but I don't know where to define it and how. In the Views, Templates, Models? And how do I write it? I know that I have to define it with a function but is there any function from django for it? </p>
  
  <p>Idea behind this queryset is to show all of the results in my database from the first examination. So in my template I have sth like this: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{% if Patient.examinationgeometry_set.filter(examination='FIRST') %}
   {% for geo in patient.examinationgeometry_set.all %}
     &lt;li&gt; x:  {{ geo.x }}&lt;br/&gt;
          c: {{ geo.c }}  &lt;br/&gt;
          b: {{ geo.b}}&lt;br/&gt;
          n: {{ geo.n}}&lt;br/&gt;
     &lt;/li&gt;
   {% endfor %}
  {% endif %}</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am thankful for every hint!</p>