title: email whitelist/blacklist in python/django
body: <p>I am writing a django app that keeps track of which email addresses are allowed to post content to a user's account. The user can whitelist and blacklist addresses as they like.</p>
  
  <p>Any addresses that aren't specified can either be handled per message or just default to whitelist or blacklist (again user specified).</p>
  
  <p>Here are the django models I wrote... do you think is a good way to do it? or should I add a whitelist and blacklist field to each user's profile model?</p>
  
  <pre><code>class knownEmail(models.Model):
      # The user who set this address' permission, NOT
      # the user who the address belongs to...
      relatedUser = models.ManyToManyField(User)
      email = models.EmailField()
  
  class whiteList(knownEmail):
      pass
  
  class blackList(knownEmail):
      pass
  </code></pre>
  
  <p>Then I could do something like:</p>
  
  <pre><code>def checkPermission(user, emailAddress):
      "Check if 'emailAddress' is allowed to post content to 'user's profile"
      if whiteList.objects.filter(relatedUser=user, email=emailAddress):
          return True
      elif blackList.objects.filter(relatedUser=user, email=emailAddress):
          return False
      else:
          return None
  </code></pre>
  
  <p>Is there a better way?</p>