title: How To Use Reverse Relations in Django Class Based Views - 2
body: <p>I'm creating a to-do list where I want the tasks to get displayed on its respective date, but I'm having a hard time doing so.</p>
  <p>I found another resource that kind of answered a similar question, but I'm still having a hard time implementing the query with reverse relations, and not quite sure how to put it on template.</p>
  <p><a href="https://stackoverflow.com/questions/28818449/using-reverse-relations-in-django-class-based-views">link</a></p>
  <p>Been spending 2 or 3 days stuck on this. Hope I could get some pointers here</p>
  <p><a href="https://i.stack.imgur.com/hkEMM.jpg" rel="nofollow noreferrer">Desired Outcome</a></p>
  <p><a href="https://i.stack.imgur.com/flIyt.jpg" rel="nofollow noreferrer">Current Outcome</a></p>
  <p>My models:</p>
  <pre><code>class Dailies(models.Model):
  
      date = models.DateField(auto_now_add=True)
  
      the_user = models.ForeignKey(
          get_user_model(),
          on_delete=models.CASCADE,
      )
  
      def __str__(self):
          return str(self.date)
  
  class DailyTask(models.Model):
      task = models.CharField(max_length=255)
      dailies = models.ForeignKey(
          Dailies,
          on_delete=models.CASCADE
      )
  
      def __str__(self):
          return self.task
  </code></pre>
  <p>My ListView:</p>
  <pre><code>class DailiesListView(LoginRequiredMixin, ListView):
      model = Dailies
  
      template_name = 'home.html'
  
      context_object_name = 'date'
  
      ordering = ['-date']
  
      
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
  
          context['date'] = context['date'].filter(the_user=self.request.user)
          context['todos'] = DailyTask.objects.filter(
              dailies__the_user=self.request.user)
  
          return context
  </code></pre>
  <p>My template (home.html):</p>
  <pre><code>{% if user.is_authenticated %}
      
      {% for each_date in date %}
      &lt;h3&gt;
          &lt;li&gt;
              {{each_date}}: 
              {% for todo in todos %} 
                  {{todo}}
              {% endfor %}
          &lt;/li&gt;  
      &lt;/h3&gt;   
      {% endfor %}
  
  {% else %}
      ...
  {% endif %}
  </code></pre>