Commits

Tom von Schwerdtner  committed dfc4dde

command to geocode uncoded citations

  • Participants
  • Parent commits e538d6e

Comments (0)

Files changed (1)

File app/citations/management/commands/citations_geocode.py

+import time
+
+from django.core.management.base import BaseCommand, CommandError
+from citations.models import Citation, Violation
+
+class Command(BaseCommand):
+    args = '<int>'
+    help = 'Geocode specified number of citations'
+    
+    def handle(self, *args, **options):
+        num = int(args[0])
+        
+        for c in Citation.objects.filter(geometry__isnull=True)[:num]:
+            print "Geocoding", c.citation
+            c.geocode(save=True)
+            time.sleep(1)