title: Django View Problem. Filtered Tickets Are Not Appearing
body: <p>I'm currently working on a project in Django that is a &quot;bug tracker&quot; or &quot;ticket tracker&quot; as some might call it. The goal here is to create a post or &quot;ticket&quot; that details a bug in the website or software for a development team.</p>
  <p>Each &quot;ticket&quot; has general information like name, summary, etc. but also has a &quot;category&quot; for the software languages or bug type(Think like categories for a blog). Every ticket also has a &quot;priority&quot;, that is developed in a similar way as to the categories, based on the severity of the bug that a reporter encounters.</p>
  <p>I have already developed a way to click on a category name and view a list of tickets within the same category. This is successful and it works great! Naturally, my next step in the process is to use that same method of implementing ticket priorities. My goal is to be able to click on a priority and see a filtered view of all &quot;severe&quot; tickets with that priority, just like how my categories are set up.</p>
  <p>Here is my problem:</p>
  <p>When I click on a priority (low, medium, high, &amp; severe), it will take me to my ticket_priority.html template for that particular priority, <strong>but does not filter or show any ticket of that priority when there is in fact ticket with that priority</strong>. All I'm trying to do is to take that same methodology of building out &quot;categories&quot; but implementing them as &quot;priorities&quot; for the team to filter out based on the severity of the bug.</p>
  <p>I think there is something wrong with my ticket_priority view, but I just don't know what the deal is and need extra eyes.</p>
  <p>First here is my models:</p>
  <pre><code>from django.db import models
  from django.utils.timezone import timezone
  from datetime import datetime
  # Create your models here.
  
  #Priority
  class Priority(models.Model):
      name = models.CharField(max_length=20,null=True)
  
      def __str__(self):
          return self.name
  
  #Category
  class Category(models.Model):
      name = models.CharField(max_length=20)
  
      def __str__(self):
          return self.name 
  
  
  #TICKET
  class Ticket(models.Model):
      #BugID
      id = models.AutoField(primary_key=True)
      title = models.CharField(max_length=100, blank=True, null=True)
      reporter = models.CharField(max_length=100, blank=True, null=True)
      created_on = models.DateTimeField(auto_now_add=True, blank=True, null=True)
      last_modified = models.DateTimeField(auto_now=True)
      
      #BugOverview
      summary = models.TextField(blank=True, null=True)
      url = models.URLField(blank=True, null=True)
      image = models.ImageField(upload_to='media/images/', blank=True, null=True)
  
      #BugEnvironment
      platform = models.CharField(max_length=20, blank=True, null=True)
      operating_system = models.CharField(max_length=20, blank=True, null=True)
      browser = models.CharField(max_length=20, blank=True, null=True)
      categories = models.ManyToManyField('Category', related_name='posts')
   
      #BugDetails
      steps_to_reproduce = models.TextField(blank=True, null=True)
      expected_result = models.CharField(max_length=100, blank=True, null=True)
      actual_result = models.CharField(max_length=100, blank=True, null=True)
      
      #BugTracking
      priorities = models.ManyToManyField('Priority', related_name='posts')
      assigned_to = models.CharField(max_length=100, blank=True, null=True)
      completed = models.BooleanField(db_column='Completed', default=False)
      datecompletion = models.DateTimeField(db_column='DateCompletion', blank=True, null=True)
  
      def set_completion(self):
          self.completed = True
          self.datecompletion = datetime.now()
          self.save()
      
      def __str__(self):
          return self.title
  </code></pre>
  <p>Next up is my views.py for ticket_category &amp; ticket_priority:</p>
  <pre><code># TICKET CATEGORY INDEX 
  
  @login_required(login_url='/accounts/login/')
  def ticket_category(request, category):
      tickets = Ticket.objects.filter(
          categories__name__contains = category
      )
      context = {
          &quot;category&quot;: category, 
          &quot;tickets&quot;: tickets
      }
      return render(request, 'ticket_category.html', context)
  
  #################################################################3
  
  # TICKET PRIORITY INDEX
  
  @login_required(login_url='/accounts/login/')
  def ticket_priority(request, priority):
      tickets = Ticket.objects.filter(
          priorities__name__contains = priority
      )
      context = {
          &quot;priority&quot;: priority, 
          &quot;tickets&quot;: tickets
      }
      return render(request, 'ticket_priority.html', context)
  
  </code></pre>
  <p>And here is my ticket_category.html template:</p>
  <pre><code>{% extends &quot;base.html&quot; %}
  {% load static %} 
  {% block page_content %}
  
  &lt;div class = &quot;container&quot;&gt; 
      
      &lt;div class = &quot;row&quot;&gt; 
  
          &lt;!-- Post Content Column --&gt;
          &lt;div class=&quot;col-lg-8&quot;&gt;
              &lt;h1&gt; {{ category | title }} &lt;/h1&gt;
              {% for ticket in tickets %}
              &lt;div class=&quot;card&quot;&gt;
                  {% for priority in ticket.priorities.all %}
                  &lt;div class=&quot;card-header&quot;&gt;
                    Ticket #{{ ticket.id}} |
                    &lt;a href=&quot;{% url 'ticket_priority' priority.name %}&quot;&gt;
                      {{ priority.name }} 
                    &lt;/a&gt;
                  &lt;/div&gt;
                  {% endfor %}
                  &lt;div class=&quot;card-body&quot;&gt;
                    &lt;h5 class=&quot;card-title&quot;&gt;{{ ticket.title }}&lt;/h5&gt;
                    &lt;p class=&quot;card-text&quot;&gt;{{ ticket.summary|truncatewords:20 }}&lt;/p&gt;
                    &lt;p class=&quot;card-text&quot;&gt; Categories: 
                      {% for category in ticket.categories.all %}
                      &lt;a href=&quot;{% url 'ticket_category' category.name %}&quot;&gt;
                          {{ category.name }} 
                      &lt;/a&gt;
                      {% endfor %}
                    &lt;/p&gt;
                    &lt;a href=&quot;{% url 'ticket_detail' ticket.pk %}&quot; class=&quot;btn btn-primary&quot;&gt;View Ticket &lt;/a&gt;
                    &lt;a href=&quot;{% url 'edit_ticket' ticket.pk %}&quot; class=&quot;btn btn-secondary&quot;&gt;Edit Ticket &lt;/a&gt;
                    &lt;a href=&quot;{% url 'completed_ticket' ticket.pk %}&quot; class=&quot;btn btn-success&quot;&gt; Ticket Completed &lt;/a&gt;
                    &lt;a href=&quot;{% url 'delete_ticket' ticket.pk %}&quot; class=&quot;btn btn-danger&quot;&gt; Delete Ticket &lt;/a&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;br&gt;
              {% endfor %}
  
          
          &lt;/div&gt;&lt;!-- Column --&gt;
  
          {% include &quot;sidebar.html&quot; %}
      &lt;/div&gt; &lt;!-- Row --&gt;
  
  &lt;/div&gt;&lt;!-- Container--&gt;
  {% endblock %}
  </code></pre>
  <p>And here is my ticket_priority.html template:</p>
  <pre><code>{% extends &quot;base.html&quot; %}
  {% load static %} 
  {% block page_content %}
  
  &lt;div class = &quot;container&quot;&gt; 
      
      &lt;div class = &quot;row&quot;&gt; 
  
          &lt;!-- Post Content Column --&gt;
          &lt;div class=&quot;col-lg-8&quot;&gt;
              &lt;h1&gt; {{ priority | title }} &lt;/h1&gt;
              {% for ticket in tickets %}
              &lt;div class=&quot;card&quot;&gt;
                  {% for priority in ticket.priorities.all %}
                  &lt;div class=&quot;card-header&quot;&gt;
                      Ticket #{{ ticket.id}} |
                      &lt;a href=&quot;{% url 'ticket_priority' priority.name %}&quot;&gt;
                        {{ priority.name }} 
                      &lt;/a&gt;
                  &lt;/div&gt;
                  {% endfor %}
                  &lt;div class=&quot;card-body&quot;&gt;
                    &lt;h5 class=&quot;card-title&quot;&gt;{{ ticket.title }}&lt;/h5&gt;
                    &lt;p class=&quot;card-text&quot;&gt;{{ ticket.summary|truncatewords:20 }}&lt;/p&gt;
                    &lt;p class=&quot;card-text&quot;&gt; Categories: 
                      {% for category in ticket.categories.all %}
                      &lt;a href=&quot;{% url 'ticket_category' category.name %}&quot;&gt;
                          {{ category.name }} 
                      &lt;/a&gt;
                      {% endfor %}
                    &lt;/p&gt;
                    &lt;a href=&quot;{% url 'ticket_detail' ticket.pk %}&quot; class=&quot;btn btn-primary&quot;&gt;View Ticket &lt;/a&gt;
                    &lt;a href=&quot;{% url 'edit_ticket' ticket.pk %}&quot; class=&quot;btn btn-secondary&quot;&gt;Edit Ticket &lt;/a&gt;
                    &lt;a href=&quot;{% url 'completed_ticket' ticket.pk %}&quot; class=&quot;btn btn-success&quot;&gt; Ticket Completed &lt;/a&gt;
                    &lt;a href=&quot;{% url 'delete_ticket' ticket.pk %}&quot; class=&quot;btn btn-danger&quot;&gt; Delete Ticket &lt;/a&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;br&gt;
              {% endfor %}
  
          
          &lt;/div&gt;&lt;!-- Column --&gt;
  
          {% include &quot;sidebar.html&quot; %}
      &lt;/div&gt; &lt;!-- Row --&gt;
  
  &lt;/div&gt;&lt;!-- Container--&gt;
  {% endblock %}
  </code></pre>
  <p>When the ticket_priority.html template renders, everything appears (base.html, sidebar, priority title, etc) - <strong>but no tickets appear</strong> - the makes me think that its a problem with my view.</p>
  <p>Been stuck on this for over a day. No errors are thrown, just no tickets appear for any priority. They DO appear for each category though. Any help or a point in the right direction would be great. Thank you!</p>