title: How to get all messages of an Inbox in django?
body: <p>I want to get all messages belongs to an Inbox between user A and B.</p>
  
  <p>My Models.</p>
  
  <pre><code>class Inbox(models.Model):
        by_user = models.ForeignKey(User); # who starts messaging
        to_user = models.ForeignKey(User); # second user
  
  class Message(models.Model):
        sender = models.ForeignKey(User); # who starts messaging
        receiver = models.ForeignKey(User); # second user
        inbox = models.ForeignKey(Inbox); # message belongs to the inbox
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>url(r'^chat/(?P&lt;username&gt;\w+)/$', views.getMessages)
  </code></pre>
  
  <p>view.py</p>
  
  <pre><code>def getMessages(request, username):
      user = User.objects.get(username=username)
      # get the inbox related to the request.user and user
      inbox = Inbox.objects.get('Whats will I write here');
      messages = inbox.messages.all().order_by('-date')
      return render(request, "inbox/chatBox.html", {'messages': messages})
  </code></pre>
  
  <p>Someone, please help me out to correct my urls.py and view.py.</p>