I've changed that part now, but the output remains the same.
On Apr 22, 5:12 pm, Johannes Wilm <johannesw...@gmail.com> wrote:
> well, that's strange, because that part always worked and still works.
> So this line here, to get the daily values:
>
> queryset=PrecioPrueba.objects.filter(producto=producto).filter
> (mercado=mercado).filter(fecha__range=[start_date,end_date]).values
> ('fecha','pk','maximo','minimo').order_by('fecha')
>
> works just fine.
>
> What I have problems with is the part about annotating/aggregating
> values for an entire month.
>
> On Apr 22, 5:06 pm, Randy Barlow <rbar...@americanri.com> wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
>
> > Johannes Wilm wrote:
> > > At first I tried this (using postgresql):
>
> > > queryset=PrecioPrueba.objects.filter(producto=producto).filter
> > > (mercado=mercado).filter(fecha__range[start_date,end_date]).extra
> > > (select={'fecha':"date_trunc('"+frecuencia+'",fecha)"}).values
> > > ('fecha','producto','mercado','maximo','minimo').annotate(maximo=Avg
> > > ('maximo'),minimo=Avg('minimo')).order_by('fecha')
>
> > > but that just gave me all the values with the date set to the first of
> > > the month, so I figured django isn't up for the job yet. Instead I
> > > tried doing it this way:
>
> > This filter is not doing what I think you want. When you
> > .filter().filter().filter(), it's doing an OR operation, not an AND
> > operation, so you are filtering for all PrecioPrubas with
> > producto=producto OR mercado=mercado, when I think you want to filter
> > for all the price points for a particular product in a particular
> > market, which is an AND operation. Try filter(mercado=mercado,
> > producto=producto, etc...) instead!
>
> > - --
> > Randy Barlow
> > Software Developer
> > The American Research Institutehttp://americanri.com
> > 919.228.4971
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v2.0.10 (GNU/Linux)
> > Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> > iEYEARECAAYFAknvQGwACgkQw3vjPfF7QfWc7QCfTi6yJ2gqjzSnP+vMTN3vEgzD
> > PjgAnRgnV+3AgGpJUPN7TvG41QjwnbNm
> > =OAOG
> > -----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---