On Tue, Nov 13, 2012 at 8:49 PM, luke lukes wrote:
> Hi everyone. hi have these models:
>
> #models.py
>
> class Subject(models.Model):
> name = models.CharField("Name",max_length=50, blank=True)
> ...
> ...
>
> class Activity(models.Model):
> label = models.CharField("Act. name",max_length=
On Tue, Nov 13, 2012 at 11:44 PM, Vibhu Rishi wrote:
> Would this not work :
>
> count = i.objects.filter(activities=Activity).count()
>
> Where you would put the count in a for loop for the Activity and iterate
> over it.
>
> V.
>
>
> On Wed, Nov 14, 2012 at 5:05 AM, Nikolas Stevenson-Molnar <
>
Would this not work :
count = i.objects.filter(activities=Activity).count()
Where you would put the count in a for loop for the Activity and iterate
over it.
V.
On Wed, Nov 14, 2012 at 5:05 AM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:
> I'm not sure I understand. Do you want
I'm not sure I understand. Do you want the value of the "count" field in
the Activity model? In that case, you could use values:
activity_counts = i.activities.all().values('id', 'count') #Will give
you something like [{'id': 1, 'count': 3}, {'id': 2, 'count': 5}, ...]
_Nik
On 11/13/2012 3:09 PM
Hi. I don't need a total counter for all related activities. I need a
counter for each related Activity:
Invoice instance:
activity A -> counter: 3
activity B -> counter: 5
...
...
is this possible?
thanks,
Luke
Il giorno martedì 13 novembre 2012
With an Invoice instance, you can easily get the number of related
Activity objects:
i = Invoice.objects.get(pk=1)
num_activities = i.activities.all().count()
_Nik
On 11/13/2012 12:49 PM, luke lukes wrote:
> Hi everyone. hi have these models:
>
> #models.py
>
> class Subject(models.Model):
Hi everyone. hi have these models:
#models.py
class Subject(models.Model):
name = models.CharField("Name",max_length=50, blank=True)
...
...
class Activity(models.Model):
label = models.CharField("Act. name",max_length=150)
price = models.DecimalField("price", max_digits=10,
decimal_place
7 matches
Mail list logo