title: Django QuerySet filtering not working with views, showing blank view even though there are entries
body: <p>I am attempting to view a particular set of objects with a certain attribute by using QuerySet filtering, however when I use the filter, the view returns blank. Not sure if I'm using this particular filter wrong, or if I'm calling on the attribute wrong, however I accessed other attributes (as seen below, the attribute "status") and found that it worked fine.</p>
  
  <p>views.py:</p>
  
  <pre><code>from django.shortcuts import render, redirect, get_object_or_404
  from django.contrib.auth.decorators import login_required
  from django.contrib.auth.models import User
  from .models import *
  from .forms import *
  
  
  
  @login_required
  def vendorView(request):
      return render(request, 'inv/vendorInventory.html')
  
  @login_required
  def consumerView(request):
      return render(request, 'inv/consumerInventory.html')
  
  def unauthenticatedView(request):
      return render(request, 'inv/unauthenticatedInventory.html')
  ################ need to edit other views to render consumer/vendor/unauth
  
  def display_drinks(request):
      items = Drinks.objects.all()
      context = {
          'items': items,
          'header': 'Drinks',
      }
  
      if not request.user.is_authenticated:
          items = Drinks.objects.filter(status='AVAILABLE')
          context = {
              'items': items,
              'header': 'Drinks',
          }
          return render(request, 'inv/unauthenticatedInventory.html', context)
  
      elif request.user.profile.vendor:
          items = Drinks.objects.filter(donatorID=request.user.username)
          context = {
              'items': items,
              'header': 'Drinks',
          }
          return render(request, 'inv/vendorInventory.html', context)
  
      elif not request.user.profile.vendor:
          items = Drinks.objects.filter(status='AVAILABLE')
          context = {
              'items': items,
              'header': 'Drinks',
          }
          return render(request, 'inv/consumerInventory.html', context)
  </code></pre>
  
  <p>inventory/models.py:</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from users.models import *
  
  
  
  # Create your models here.
  
  class Donation(models.Model):
  
      description = models.CharField(max_length=200, blank=False, help_text='Describe your donation here')
  
      choices = ( #for status
          ('AVAILABLE', 'Item ready to be picked up'),
          ('RESERVED', 'Item reserved'),
      )
  
      expiry = models.CharField(max_length=200, blank=False, help_text="Enter expiration date here")
      status = models.CharField(max_length=10, choices=choices, default='AVAILABLE')
      misc = models.CharField(max_length=50, blank=False, help_text='Miscellaneous info about your donation')
      donatorID = models.CharField(max_length=50, default = User.username)
  
  
  
      class Meta:
          abstract = True
  
      def __str__(self):
          return '{0}'.format(self.description)
  
  
  class Foods(Donation):
      pass
  
  class Drinks(Donation):
      pass
  
  class MiscObjects(Donation):
      pass
  </code></pre>
  
  <p>As one can see, in models.py, the donatorID is assigned to the Donation object, and is the user's username. In the function display_drinks (in views.py), in the first elif, it should use the user's username to filter whatever items don't have the matching attribute, place items into a QuerySet that do match - however it displays blank, even though there are items that have matching attributes.</p>
  
  <p>Would anyone know why this is occurring?</p>
  
  <p>Thanks.</p>
  
  <p>edit: as requested, here's vendorInventory.html:</p>
  
  <pre><code>{% extends "blog/base.html" %}
  
  {% block body %}
  
  
  
  &lt;center&gt;  &lt;div class="add_buttons"&gt;
  
  
      &lt;div class="btn-group-vertical"&gt;
        &lt;a href="{% url 'display_foods' %}" class="btn btn-outline-info" role="button"&gt; View Food&lt;/a&gt;
        &lt;a href="{% url 'add_food' %}" class="btn btn-outline-info" role="button"&gt; Add Food&lt;/a&gt;
      &lt;/div&gt;
  
      &lt;div class="btn-group-vertical"&gt;
        &lt;a href="{% url 'display_drinks' %}" class="btn btn-outline-info" role="button"&gt;View Drinks&lt;/a&gt;
        &lt;a href="{% url 'add_drink' %}" class="btn btn-outline-info" role="button"&gt; Add Drink&lt;/a&gt;
      &lt;/div&gt;
  
      &lt;div class="btn-group-vertical"&gt;
        &lt;a href="{% url 'display_miscObjects' %}" class="btn btn-outline-info" role="button"&gt; View Misc&lt;/a&gt;
        &lt;a href="{% url 'add_miscObject' %}" class="btn btn-outline-info" role="button"&gt; Add Misc&lt;/a&gt;
      &lt;/div&gt;
  
  
    &lt;/div&gt;
  
    &lt;/center&gt;
  
    &lt;div&gt;
  
      &lt;h4&gt;Currently Viewing {{ header }}&lt;/h4&gt;
    &lt;/div&gt;
  
    &lt;table class="table table-hover"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;id&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
          &lt;th&gt;Expiry Date&lt;/th&gt;
          &lt;th&gt;Status&lt;/th&gt;
          &lt;th&gt;Misc&lt;/th&gt;
          &lt;th&gt;Edit/Delete&lt;/th&gt;
  
        &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
  
        {% for item in items %}
  
        &lt;tr&gt;
          &lt;td&gt;{{ item.pk }}
          &lt;td&gt;{{ item.description }}&lt;/td&gt;
          &lt;td&gt;{{ item.expiry }} &lt;/td&gt;
          &lt;td&gt;{{ item.status }}&lt;/td&gt;
          &lt;td&gt;{{ item.misc }}&lt;/td&gt;
  
          {% if header|lower == "drinks" %}
          &lt;td&gt;
              &lt;a href="{% url 'edit_drink' item.pk %}" class="btn btn-outline-info" role="button" aria-pressed="true" &gt; Edit&lt;/a&gt;
              &lt;a href="{% url 'delete_drink' item.pk%}" class="btn btn-danger btn-sm" role="button" aria-pressed="true" &gt; x &lt;/a&gt;
          &lt;/td&gt;
          {% elif header|lower == "foods" %}
          &lt;td&gt;
              &lt;a href="{% url 'edit_food' item.pk %}" class="btn btn-outline-info" role="button" aria-pressed="true" &gt; Edit&lt;/a&gt;
              &lt;a href="{% url 'delete_food' item.pk%}" class="btn btn-danger btn-sm" role="button" aria-pressed="true" &gt; x &lt;/a&gt;
          &lt;/td&gt;
          {% else %}
          &lt;td&gt;
              &lt;a href="{% url 'edit_miscObject' item.pk %}" class="btn btn-outline-info" role="button" aria-pressed="true" &gt; Edit&lt;/a&gt;
              &lt;a href="{% url 'delete_miscObject' item.pk%}" class="btn btn-danger btn-sm" role="button" aria-pressed="true" &gt; x &lt;/a&gt;
          &lt;/td&gt;
          {% endif %}
        &lt;/tr&gt;
  
        {% endfor %}
  
      &lt;/tbody&gt;
    &lt;/table&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>forms.py: </p>
  
  <pre><code>from django import forms
  from .models import *
  
  
  class DrinkForm(forms.ModelForm):
      class Meta:
          model = Drinks
          fields = ('description', 'expiry', 'status', 'misc', 'donator')
  
  
  class FoodForm(forms.ModelForm):
      class Meta:
          model = Foods
          fields = ('description', 'expiry', 'status', 'misc')
  
  
  class MiscObjectForm(forms.ModelForm):
      class Meta:
          model = MiscObjects
          fields = ('description', 'expiry', 'status', 'misc')
  
  class ReserveDrinkForm(forms.ModelForm):
      class Meta:
          model = Drinks
          fields = ('status',)
  
  
  class ReserveFoodForm(forms.ModelForm):
      class Meta:
          model = Foods
          fields = ('status',)
  
  
  class ReserveMiscObjectForm(forms.ModelForm):
      class Meta:
          model = MiscObjects
          fields = ('status',)
  </code></pre>