本文整理匯總了Python中django.conf.settings.GOOGLE_API_KEY屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.GOOGLE_API_KEY屬性的具體用法?Python settings.GOOGLE_API_KEY怎麽用?Python settings.GOOGLE_API_KEY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.GOOGLE_API_KEY屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
def setUp(self):
self.region = "Somerville, MA"
self.addresses = ["240 Elm Street", "100 Broadway", "115 Medford Street"]
self.geocoder = gmaps.GoogleGeocoder(settings.GOOGLE_API_KEY)
self.proposal_importer_url = "https://58kr1azj04.execute-api.us-east-1.amazonaws.com/prod/somervillema"
示例2: get_context_data
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if settings.GOOGLE_API_KEY:
context['GOOGLE_API_KEY'] = settings.GOOGLE_API_KEY
return context
示例3: get_site_addr_loc
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
def get_site_addr_loc(tags, site_id, session):
show_google_map = False
addr_loc = None
site_address = ""
allowed_tags = ['geoCity', 'geoCountry', 'geoPostalCode', 'geoState', 'geoStreet', 'geoAddr']
geo_addr = None
if settings.GOOGLE_API_KEY:
if tags:
for tag in tags:
if tag in allowed_tags and tags[tag]:
if tag == 'geoAddr':
geo_addr = tags[tag]
continue
if site_address:
site_address = site_address + ", "
site_address = site_address + tags[tag]
if tag == 'geoStreet':
show_google_map = True
if not show_google_map and geo_addr:
if site_address:
site_address = site_address + ", "
site_address = site_address + geo_addr
show_google_map = True
if site_address and show_google_map:
hash_object = hashlib.md5(site_address.encode('utf-8'))
hash_key = hash_object.hexdigest()
if hash_key in session:
addr_loc = session[hash_key]
if not addr_loc:
geo = geocoder.google(site_address, key=settings.GOOGLE_API_KEY)
if geo.json and geo.json["ok"]:
addr_loc = {"latitude": geo.json["lat"], "longitude": geo.json["lng"], "site_id": site_id}
session[hash_key] = addr_loc
return addr_loc
示例4: analytics
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
def analytics(request):
return {"GOOGLE_API_KEY": settings.GOOGLE_API_KEY, "HOTJAR_TRACKING_KEY": settings.HOTJAR_TRACKING_KEY}
示例5: global_settings
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
def global_settings(request):
# return any necessary values
return {
'GOOGLE_ANALYTICS': settings.GOOGLE_ANALYTICS,
'GOOGLE_API_KEY': settings.GOOGLE_API_KEY
}
示例6: api_keys
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_API_KEY [as 別名]
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,
"GOOGLE_TAG_MANAGER": settings.GTM_CONTAINER_ID,
"SMARTLOOK": settings.SL_TRACKING_ID,
}
}