title: django querysets in templates
body: <p>I am trying to make specific queries by using some model entry fields.
  I have the following model entry:</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Work(models.Model):
  
      categories =(
                  ('cat1', 'cat1'),
                  ('cat2', 'cat2'),
                  ('cat3', 'cat3'),
                  ('cat4', 'cat4'),
                  ('cat5', 'cat5'),
                  )
      title = models.CharField(max_length=200)
      description = RichTextUploadingField(config_name='awesome_ckeditor')
      date = models.DateTimeField(default=timezone.now)
      category = models.CharField(max_length=200, choices = categories, default = 'projects')
      thumb = models.ImageField(upload_to = 'works/thumbs', blank = True)
      content = models.FileField(upload_to = 'works/content_media', blank = True)
      published = models.BooleanField()
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse("work_detail",kwargs={'pk':self.pk})
      @property
      def thumb_url(self):
          if self.thumb and hasattr(self.thumb, 'url'):
              return self.thumb.url
      @property
      def content_url(self):
          if self.content and hasattr(self.content, 'url'):
              return self.content.url
  </code></pre>
  
  <p>here is the view:</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class WorksListView(ListView):
      template_name = 'template.html'
      model = Work
  
      def get_queryset(self):
          return Work.objects.filter(published=True).order_by('-date')
  </code></pre>
  
  <p>and I am trying to query first by the category field then by entry in the following template:</p>
  
  <p><strong>template.html</strong></p>
  
  <pre><code>{% for category in works_list.category %}
      &lt;ul data-category-name={{category.name}}&gt;
      {% for work in category.works %}
          &lt;li data-thumbnail-path={{thumbnail.url}} data-url={{content.url}} &gt;
              &lt;div&gt;
                  &lt;p class="gallery1DecHeader"&gt;{{work.title}}&lt;/p&gt;
                  &lt;p class="gallery1DescP"&gt;{{work.description}}&lt;/p&gt;
              &lt;/div&gt;
          &lt;/li&gt;
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>what do I need to change?</p>