我有这两个模型:
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
我想做的是根据日志条目显示谷歌地图,所以我应该传递给模板的是这样的:
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Popularity'],
['Germany', 200],
['United States', 300],
['Brazil', 400],
['Canada', 500],
['France', 600],
['RU', 700]
]);
提取数据并将其传递给模板的最快方法是什么?