我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用django.conf.settings.GOOGLE_API_KEY。
def clean(self): if self.is_current and not self.is_osedev: raise ValidationError({ 'is_current': _("To enable current status a user must also be an OSE Developer.") }) if not self.location: self.latitude = None self.longitude = None self.location_details = None elif settings.GEOCODE_ENABLED and settings.GOOGLE_API_KEY: if not self.__original_location or (self.__original_location != self.location): gmaps = googlemaps.Client(key=settings.GOOGLE_API_KEY) self.location_details = gmaps.geocode(self.location) if self.location_details: self.latitude = self.location_details[0]['geometry']['location']['lng'] self.longitude = self.location_details[0]['geometry']['location']['lat']
def get_google_request(self): return requests.post('https://maps.googleapis.com/maps/api/geocode/json?address='+self.name.replace(' ', '+')+'&key='+settings.GOOGLE_API_KEY)
def get_photo(placeId): r = requests.post( 'https://maps.googleapis.com/maps/api/place/details/json?placeid=' + placeId + '&key=' + settings.GOOGLE_API_KEY) ref = r.json()['result']['photos'][0]['photo_reference'] photo = requests.post( 'https://maps.googleapis.com/maps/api/place/photo?photoreference=' + ref + '&maxwidth=3000&key=' + settings.GOOGLE_API_KEY) return photo.url
def api_keys(request): """ Pass a `APIKEYS` dictionary into the template context, which holds IDs and secret keys for the various APIs used in this project. """ return { "APIKEYS": { "GOOGLE": settings.GOOGLE_API_KEY, "GOOGLE_ANALYTICS": settings.GA_TRACKING_ID, "GOOGLE_ADWORDS": settings.ADWORDS_CONVERSION_ID, "SMARTLOOK": settings.SL_TRACKING_ID, } }
def import_progress(qs=None): service = discovery.build('sheets', 'v4', developerKey=settings.GOOGLE_API_KEY) for product in qs or Product.objects.all(): product.import_progress(service)
def reachus(request): context = {} context["google_api_key"] = settings.GOOGLE_API_KEY return render(request, 'festflow/reachus.html', context)
def __init__(self, *args, **kwargs): super(Client, self).__init__( key=settings.GOOGLE_API_KEY)
def _set_lat_lng(self): gmaps = googlemaps.Client(key=settings.GOOGLE_API_KEY) geocode = gmaps.geocode(self.address) if len(geocode) > 0: self.latitude = geocode[0]['geometry']['location']['lat'] self.longitude = geocode[0]['geometry']['location']['lng']
def api_key(): try: return settings.GOOGLE_API_KEY except AttributeError: return ''
def handle(self, *args, **options): ocd_ids = [] if options['infile']: for ocd_id in options['infile']: ocd_ids.append(ocd_id.strip()) else: ocd_ids = options['ocd_id'] service = build('civicinfo', 'v2', developerKey=settings.GOOGLE_API_KEY) resource = service.representatives() for ocd_id in ocd_ids: request = resource.representativeInfoByDivision( ocdId=ocd_id, roles='legislatorLowerBody') response = request.execute() division = response['divisions'][ocd_id] office_index = response['divisions'][ocd_id]['officeIndices'][0] office = response['offices'][office_index] official_index = office['officialIndices'][0] official = response['officials'][official_index] division_model, created = self._create_division(ocd_id, division) office_model, created = self._create_office(office, division_model) official_model, created = self._create_official(official, office_model)
def search_images(query): payload = { 'q': query, 'cx': settings.GOOGLE_SEARCH_ENGINE_ID, 'key': settings.GOOGLE_API_KEY, 'searchType': 'image', } r = requests.get("https://www.googleapis.com/customsearch/v1", params=payload) if not r.ok: if r.status_code == 403: # send msg to logger pass return flatten(r)