Daniel Greenfeld  committed d2daaec

Adding Google API key to help when you get blocked

  • Participants
  • Parent commits 946bb6f

Comments (0)

Files changed (2)

 Then add 'easy_maps' to INSTALLED_APPS and run ``./ syncdb``
 (or ``./ migrate easy_maps`` if South is in use)
+If working on localhost you can run into Google Maps API lockdown. If this happens
+then create a EASY_MAPS_GOOGLE_KEY in your file::
+    EASY_MAPS_GOOGLE_KEY = "your-google-maps-api-key"

File easy_maps/

+from django.conf import settings
 from django.db import models
 from django.utils.encoding import smart_str
 from geopy import geocoders
             self.geocode_error = True
-            g = geocoders.Google(resource='maps')
+            if hasattr(settings, "EASY_MAPS_GOOGLE_KEY"):
+                g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY)
+            else:
+                g = geocoders.Google(resource='maps')
             address = smart_str(self.address)
             self.computed_address, (self.latitude, self.longitude,) = g.geocode(address)
             self.geocode_error = False