2009/2/10 Russell Keith-Magee <freakboy3...@gmail.com>

>
>
> However, if you're using Django trunk, what you want is:
>
> >>> from django.db.models import Max
> >>> qs =
> Module_scheme.objects.filter(plant=3).annotate(max_energy_tot=Max('module__energy_tot'))
> >>> for mod in qs:
> ...    print mod.id, mod.max_energy_tot
>
> That is - retrieve a list of Module_scheme objects associated with
> plant 3, and annotate each one of which is annotated with the maximum
> of the energy_tot of the modules related to the Module_scheme. The
> maximum is provided as an extra attribute on each of the Module_scheme
> instance.


I cannot do this because I have a ForeignKey from Module to Module_Scheme,
and your first line returns

FieldError: Cannot resolve keyword 'module' into field. Choices are: id,
jbox, module_number, modules, plant, rack_number


Can I solve this problem?

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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

Reply via email to