Select value by id

0

I have a question, in my view.py I have a question

example

ing =ingresos.objects.values('id').annotate(Sum('precio'))

works fine but as you will see in the tamplete I "paint" all the values in the database, how could that query to only show the annotate (value) according to the id of the establishment

url.py

url(r'^detalle_establecimiento/(?P<id_establecimiento>\d+)$','principal.views.detalle_establecimiento'),

I know that the culsulta that I do gives me back the correct value because I do it to all the objects of a model, but I want to select the value that corresponds to each establishment, that is id

    
asked by Roly Miranda Díaz 02.05.2017 в 16:27
source

1 answer

0

If you are starting from a DataFrame, the simplest thing is to apply a grouping and at the end the addition function:

ing.groupby('ID').sum()

    
answered by 04.05.2017 в 00:39