當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.GOOGLE_MAPS_API_KEY屬性代碼示例

本文整理匯總了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
    }) 
開發者ID:sibtc,項目名稱:restful-apis-example,代碼行數:21,代碼來源:views.py

示例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 
開發者ID:PacktPublishing,項目名稱:Django-3-Web-Development-Cookbook-Fourth-Edition,代碼行數:27,代碼來源:admin2.py

示例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
    } 
開發者ID:grupyrn,項目名稱:jararaca,代碼行數:6,代碼來源:context_processors.py


注:本文中的django.conf.settings.GOOGLE_MAPS_API_KEY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。