code: def is_valid_consumer(request):
      
      try:
          ip = request.META.get('REMOTE_ADDR', None)
          return Consumer.objects.get(key=request.key, ip=ip).allowed
      except Consumer.DoesNotExist:
          consumers = Consumer.objects.filter(key=request.key, allowed=True)
          return not consumers.exists()
docs: Validate the client for view/resource access with the given key
      
      The client is authorized to access the view:
          - if there is a `Consumer` with the client's *IP* that is explicitly allowed to use the given key,
          - if there is no `Consumer` with a different *IP* explicitly allowed to use the given key