0

I need to open my gmap in a few pages:

{% block extra_js %}
    <script src="{%static 'js/map.js' %}" type="text/javascript"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAZY5nutUGjjf4D...endOFKEY&callback=initMap"async defer></script>
{% endblock %}

and sometimes keys get expired. It's really annoying to change the key in every html file I have. Maybe I can make some sort of a global varialbe and store the key there? Any suggestions?

nutella_eater
  • 3,393
  • 3
  • 27
  • 46

1 Answers1

0

Put this on you settings.py

TEMPLATES[0]['OPTIONS']['context_processors'].append("API_KEY : YOUR_API_KEY")

then use {{API_KEY}} on your template as a variable. for more info check: Django - How to make a variable available to all templates?

Community
  • 1
  • 1