Python django.conf.settings.GOOGLE_MAPS_API_KEY Examples

The following are 7 code examples of django.conf.settings.GOOGLE_MAPS_API_KEY(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source Project: restful-apis-example   Author: sibtc   File: views.py    License: MIT License 6 votes vote down vote up
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
    }) 
Example #2
Source Project: Django-3-Web-Development-Cookbook-Fourth-Edition   Author: PacktPublishing   File: admin2.py    License: MIT License 6 votes vote down vote up
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 
Example #3
Source Project: Django-3-Web-Development-Cookbook-Fourth-Edition   Author: PacktPublishing   File: admin2.py    License: MIT License 6 votes vote down vote up
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 
Example #4
Source Project: Django-3-Web-Development-Cookbook-Fourth-Edition   Author: PacktPublishing   File: admin2.py    License: MIT License 6 votes vote down vote up
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 
Example #5
Source Project: Django-3-Web-Development-Cookbook-Fourth-Edition   Author: PacktPublishing   File: admin2.py    License: MIT License 6 votes vote down vote up
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 
Example #6
Source Project: Django-3-Web-Development-Cookbook-Fourth-Edition   Author: PacktPublishing   File: context_processors.py    License: MIT License 5 votes vote down vote up
def google_maps(request):
    return {
        "GOOGLE_MAPS_API_KEY": settings.GOOGLE_MAPS_API_KEY,
    } 
Example #7
Source Project: jararaca   Author: grupyrn   File: context_processors.py    License: GNU General Public License v3.0 5 votes vote down vote up
def global_settings(request):
    return {
        'GOOGLE_MAPS_API_KEY': settings.GOOGLE_MAPS_API_KEY
    }