Hello,
i think this is the right answer:
from django.db.models import Sum ModelName.objects.filter(field_name__isnull=True).aggregate(Sum('field_name')) # returns {'field_name__sum': 1000} for exampleHello friends--please i have: conversion_fqctor = models.charfield(choices=FACTOR)i want to sum the conversion_factor inside my view.py how do i convert it to a decimal and use the Sum()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALYpPT8_5sMsyjzvpdGZ3gBQbqiwQW7EHgZ61i4LdLQ1z38LYg%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9mzh5hoTgESsxFiUtkT_S-cPvTSjNGp-zUAfSwSptAaZJw%40mail.gmail.com.
No comments:
Post a Comment