title: Django refresh session to obtain any new messages for user
body: <p>I'm trying to do a simple push protocol for <a href="https://docs.djangoproject.com/en/1.10/ref/contrib/messages/" rel="nofollow">django messages</a>. So in my REST call, I have the following snippet:</p>
  
  <pre><code>    storage = get_messages(self.request)
      res = dict(messages=[dict(level=item.level, message=item.message) for item in storage])
  
      now = monotonic()
      while not res.messages and monotonic() - now &lt; 15:
          sleep(.5)
          res.messages = [dict(level=item.level, message=item.message) for item in storage]
  </code></pre>
  
  <p>Naturally, the while loop does nothing because the messages framework simply re-reads the session variable which only "updates" on new requests.</p>
  
  <p>I tried going into the underlying code to see if there was anything about updating the storage on the fly, but there seems to be no code that would do this, at least in the messaging framework. There was this promising undocumented <code>storage.update()</code> method, but it turned out to do something else.</p>
  
  <p>So, is there anything in Django framework that would allow me to poll for any messages changes and report that to the browser when it happens? Or a different method that would achieve the same thing more elegantly?</p>