GeoDjango and Taco Bell

I’ve been at it again with GeoDjango , this time I’ve pulled data on all Taco Bells locations from a popular social media site, took that data and added to a Django project, and finally plotted them in a view using Google Maps :

Screen Shot 2015-11-22 at 8.13.51 AM

Wow, that is a lot of Taco Bells !

Since this is Django, we are also able to view and edit from the admin :

Screen Shot 2015-11-22 at 8.15.13 AM

As well as the shell :

Screen Shot 2015-11-22 at 8.15.47 AM

django-cities was used tie it all together, which allows me to do searches like how many Taco Bells do the cities with the highest population have:

In [1]: from cities.models import City

In [2]: from hub.models import Location

In [3]: for city in City.objects.order_by('-population')[:20]:
    locations = Location.objects.filter(cities_city=city)
    print '%s with population %s has %s Taco Bells' % (
      city.name, city.population, len(locations))
   ...:
New York City with population 8175133 has 0 Taco Bells
Los Angeles with population 3792621 has 34 Taco Bells
Chicago with population 2695598 has 15 Taco Bells
Brooklyn with population 2300664 has 5 Taco Bells
Borough of Queens with population 2272771 has 0 Taco Bells
Houston with population 2099451 has 54 Taco Bells
Philadelphia with population 1526006 has 13 Taco Bells
Manhattan with population 1487536 has 1 Taco Bells
Phoenix with population 1445632 has 34 Taco Bells
The Bronx with population 1385108 has 0 Taco Bells
San Antonio with population 1327407 has 22 Taco Bells
San Diego with population 1307402 has 22 Taco Bells
Dallas with population 1197816 has 27 Taco Bells
San Jose with population 945942 has 18 Taco Bells
Indianapolis with population 829718 has 30 Taco Bells
Jacksonville with population 821784 has 18 Taco Bells
San Francisco with population 805235 has 11 Taco Bells
Austin with population 790390 has 25 Taco Bells
Columbus with population 787033 has 23 Taco Bells
Fort Worth with population 741206 has 16 Taco Bells

Or how may Taco Bells each state in the United State has:

In [1]: from cities.models import Region

In [2]: from hub.models import Location

In [3]: for region in Region.objects.all()[:10]:
    locations = Location.objects.filter(cities_state=region)
    print '%s has %s Taco Bells' % (region.name, len(locations))
   ...:
Arkansas has 58 Taco Bells
Washington, D.C. has 5 Taco Bells
Delaware has 14 Taco Bells
Florida has 363 Taco Bells
Georgia has 193 Taco Bells
Kansas has 65 Taco Bells
Louisiana has 92 Taco Bells
Maryland has 91 Taco Bells
Missouri has 157 Taco Bells
Mississippi has 48 Taco Bells