Hello,

I'm trying to get an aggregate to work. These are the (abridged) domain objects:

  class Site(models.Model):
      name = models.CharField(max_length=512)

  class Archive(models.Model):
      site = models.ForeignKey(Site)
      file_system_object = models.FileField(upload_to='.')
      downloads = models.PositiveIntegerField()

That is, each "Site" can have any number of "Archive". I'd like to
aggregate, and annotate, the total size of archives for each site.

Just for the sake of testing, and to verify that the "plumbing"
(relations) work, I can readily do

  Site.objects.annotate(downloads=Sum('archive__downloads'))

and I'm getting what I expect. But I just hit a roadblock with the
size, since it is an attribute of file_system_object.

Can I aggregate over a field property?

Best regards,
Carlos.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to