'Ensure that field can be summed over correctly.'

def test_sum(self):

    ages = [23, 54, 12, 94, 27]
    for (i, age) in enumerate(ages):
        self.Person(name=('test%s' % i), age=age).save()
    self.assertEqual(self.Person.objects.sum('age'), sum(ages))
    self.Person(name='ageless    person').save()
    self.assertEqual(self.Person.objects.sum('age'), sum(ages))
    for (i, age) in enumerate(ages):
        self.Person(name=('test    meta%s' % i), person_meta=self.PersonMeta(weight=age)).save()
    self.assertEqual(self.Person.objects.sum('person_meta.weight'), sum(ages))
    self.Person(name='weightless    person').save()
    self.assertEqual(self.Person.objects.sum('age'), sum(ages))
    self.assertEqual(self.Person.objects.filter(age__gte=50).sum('age'), sum([a for a in ages if (a >= 50)]))
