title: Groupchat Database design with POSTGRES and DJANGO
body: <p>I have managed to create a django backend model which will be used to create a groupchat application,
  These are the tables I am using:</p>
  <ul>
  <li><strong>User</strong>: from Django.contrib.auth.models</li>
  <li><strong>Group</strong>: name, description</li>
  <li><strong>GroupUsers</strong>: <em>group</em> (f.key to Group), <em>user</em> (f.key to User), isAdmin</li>
  <li><strong>Message</strong>: <em>user</em> (f.key to User), <em>group</em> (f.key to Group), message, timestamp ....</li>
  </ul>
  <p>My problem is that with this model, it allows ANY user to write to ANY group, which is obviously a problem, how would I enforce a constraint in a django models.py file to ensure that this does not happen?</p>
  <p>Here is my models.py file:
  <a href="https://i.stack.imgur.com/j99eb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j99eb.png" alt="enter image description here" /></a></p>