Skip to main content

UNKNOWN

Project description

This is a small Django utility module to allow you to correctly annotate or aggregate based on the sum of a Boolean field. This answers the question “how many objects do I have related to this object where foo is True.

Usage

Usage is pretty simple:

from django_boolean_sum import BooleanSum

MyModel.objects.annotate(priority_related_count=BooleanSum('related__priority'))

This will return instances of MyModel with a related_count attribute, which is the number of related instances which have priority=True.

Installation

From PyPI:

$ pip install django-boolean-sum

Caveats

This has been tested solely on PostgreSQL and Sqlite, using Django 1.4. It also depends on internal Django components which are not documented, and therefore are subject to possible breaking changes in future versions.

It is very naive about multi-databases, assuming that the query is being made for the backend of the default database.

Contributing

Pull Request it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-boolean-sum-0.1.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file django-boolean-sum-0.1.tar.gz.

File metadata

File hashes

Hashes for django-boolean-sum-0.1.tar.gz
Algorithm Hash digest
SHA256 b5b7ca303a49a40cf1ede144038dffbbadd0b9e84882658dd9e984580dbe51fc
MD5 47e1a4bc5e6c17f2acf34f6694802143
BLAKE2b-256 d58436938d8668b3c558eb57d5ecd33ad0ca35070588b591f51f14ff41b193fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page