title: How to set up communication between two apps in Django?
body: <p>I am currently trying to build a web app Todo task manager with Django as I find that the best way to learn is to get your hands dirty but I have come across a problem and I don't really know what is the Django way of doing it..</p>
  
  <p>At the moment I have two apps in my project, one is 'lists' and the second is 'tasks', and my problem is that on the frontend, I need to show the different lists and associate them the tasks that are related to each list. So far I have managed to get the result visually by giving a list id to my tasks using a foreign key and importing the 'Task' model to the 'lists' views.py to then do the query for tasks within the views.py of the lists app so that I can loop through them on the frontend but I feel like I'm making a frankeistein app now as they are both interdependent</p>
  
  <p>How would you guys handle the situation?</p>
  
  <p>ps: here an excerpt of my code for context </p>
  
  <pre><code>from tasks.models import Task
  
  
  def lists_view(request):
      lists = List.objects.all()
      tasks = Task.objects.all()
      print("The request: ", request)
      context = {
          'lists': lists,
          'tasks': tasks,
      }
      for list in lists:
          print("List: ", list)
  
      return render(request, 'lists/lists.html', context)
  
  
  def list_view(request, pk):
      list = List.objects.get(id=pk)
      tasks = Task.objects.all()
      print(request)
      context = {
          'list': list,
          'tasks': tasks,
      }
      return render(request, 'lists/list.html', context)
  </code></pre>
  
  <p>And the html:</p>
  
  <pre><code>{% for list in lists %}
  &lt;h1&gt;&lt;a href="{% url 'list-detail' list.id %}"&gt;{{ list.title|title }}&lt;/a&gt;&lt;/h1&gt;
  &lt;ul&gt;
      {% for task in tasks %}
      {% if task.list.id == list.id%}
  
      &lt;li&gt;&lt;a href="{% url 'task-detail' task.id %}"&gt;{{ task.title|capfirst }}&lt;/a&gt;&lt;/li&gt;
  
      {% endif %}
      {% endfor %}
  &lt;/ul&gt;
  {% endfor %}
  </code></pre>