本文整理匯總了Python中django.conf.settings.GOOGLE_MAPS_API_KEY屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.GOOGLE_MAPS_API_KEY屬性的具體用法?Python settings.GOOGLE_MAPS_API_KEY怎麽用?Python settings.GOOGLE_MAPS_API_KEY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.GOOGLE_MAPS_API_KEY屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: home
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_MAPS_API_KEY [as 別名]
def home(request):
is_cached = ('geodata' in request.session)
if not is_cached:
ip_address = request.META.get('HTTP_X_FORWARDED_FOR', '')
params = {'access_key': settings.IPSTACK_API_KEY}
response = requests.get('http://api.ipstack.com/%s' % ip_address, params=params)
request.session['geodata'] = response.json()
geodata = request.session['geodata']
return render(request, 'core/home.html', {
'ip': geodata.get('ip'),
'country': geodata.get('country_name', ''),
'latitude': geodata.get('latitude', ''),
'longitude': geodata.get('longitude', ''),
'api_key': settings.GOOGLE_MAPS_API_KEY,
'is_cached': is_cached
})
示例2: get_fieldsets
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_MAPS_API_KEY [as 別名]
def get_fieldsets(self, request, obj=None):
map_html = render_to_string(
"admin/locations/includes/map.html",
{"MAPS_API_KEY": settings.GOOGLE_MAPS_API_KEY},
)
fieldsets = [
(_("Main Data"), {"fields": ("name", "description")}),
(
_("Address"),
{
"fields": (
"street_address",
"street_address2",
"postal_code",
"city",
"country",
"latitude",
"longitude",
)
},
),
(_("Map"), {"description": map_html, "fields": []}),
(_("Image"), {"fields": ("picture",)}),
]
return fieldsets
示例3: google_maps
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_MAPS_API_KEY [as 別名]
def google_maps(request):
return {
"GOOGLE_MAPS_API_KEY": settings.GOOGLE_MAPS_API_KEY,
}
開發者ID:PacktPublishing,項目名稱:Django-3-Web-Development-Cookbook-Fourth-Edition,代碼行數:6,代碼來源:context_processors.py
示例4: global_settings
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import GOOGLE_MAPS_API_KEY [as 別名]
def global_settings(request):
return {
'GOOGLE_MAPS_API_KEY': settings.GOOGLE_MAPS_API_KEY
}