I have two models:
class Log(models.Model): ... country = models.ForeignKey(Country, null=True, blank=True) ... user = models.ForeignKey('auth.User') class Country(models.Model): name = models.CharField(max_length=50) alpha_2_code = models.CharField("Alpha-2 code", max_length=2, unique=True) alpha_3_code = models.CharField("Alpha-3 code", max_length=3, unique=True) numeric_code = models.PositiveSmallIntegerField("Numeric code", max_length=3, unique=True) order = models.SmallIntegerField(max_length=3) continent = models.ForeignKey(Continent) def __unicode__(self): return self.name
What I'm trying to do is display a Google Map based on log entries, so what I have to pass to the templates looks something like this:
function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', 'Popularity'], ['Germany', 200], ['United States', 300], ['Brazil', 400], ['Canada', 500], ['France', 600], ['RU', 700] ]);
What is the fastest way to extract and pass data to templates?
source share