code: def get_s3_client():
      
      session_kwargs = {}
      if hasattr(settings, 'AWS_ACCESS_KEY_ID'):
          session_kwargs['aws_access_key_id'] = settings.AWS_ACCESS_KEY_ID
  
      if hasattr(settings, 'AWS_SECRET_ACCESS_KEY'):
          session_kwargs['aws_secret_access_key'] = settings.AWS_SECRET_ACCESS_KEY
      boto3.setup_default_session(**session_kwargs)
  
      s3_kwargs = {}
      if hasattr(settings, 'AWS_S3_ENDPOINT'):
          s3_kwargs['endpoint_url'] = settings.AWS_S3_ENDPOINT
      elif hasattr(settings, 'AWS_S3_HOST'):
          if hasattr(settings, 'AWS_S3_USE_SSL') and settings.AWS_S3_USE_SSL is False:
              protocol = "http://"
          else:
              protocol = "https://"
          s3_kwargs['endpoint_url'] = "{}{}".format(
              protocol,
              settings.AWS_S3_HOST
          )
      if hasattr(settings, "AWS_REGION"):
          s3_kwargs['region_name'] = settings.AWS_REGION
      s3_client = boto3.client('s3', **s3_kwargs)
      s3_resource = boto3.resource('s3', **s3_kwargs)
      return s3_client, s3_resource
docs: A DRY place to make sure AWS credentials in settings override
      environment based credentials.  Boto3 will fall back to:
      http://boto3.readthedocs.io/en/latest/guide/configuration.html