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.2.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

django_boolean_sum-0.2-py2-none-any.whl (3.4 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for django-boolean-sum-0.2.tar.gz
Algorithm Hash digest
SHA256 2902c9d78d89519acdc3ab631d9a0a25cc7d563699dbbbbecb1af81456ab7db6
MD5 b78681453bd6ae6f71dfe9e8e419f253
BLAKE2b-256 566389e7987b4f498a17dc54dc17d67ab1db764e8a654369be75f5c0d2dbd88e

See more details on using hashes here.

File details

Details for the file django_boolean_sum-0.2-py2-none-any.whl.

File metadata

File hashes

Hashes for django_boolean_sum-0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 e71e1ed4c18f64ff6e5cffcfc17696f4829304f4565bcd69142f1da4071170ff
MD5 d9069a0461b2d55fd1b91ed3e15f8e72
BLAKE2b-256 82e6206a39d9f72afa0bd276bc3f5bdff20faee77b37450d3da7184f2788c3e5

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