Skip to main content

Caching count() in django models

Project description

Usage

from django_cached_counts import CachedCount

class MyModel(models.Model):
    bar = models.ManyToManyField(Bar)
    foo_count = CachedCount("foo_set", filter=Q(foo__x__gte=10))
    total_user_count = CachedCount(User.objects.all())
    m2m_count = CachedCount('bar_set')

class Foo(models.Model):
    mymodel = models.ForeignKey(MyModel)

Those counts would be cached and invalidated when models Foo or User are saved/deleted

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_cached_counts-0.2.1.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

django_cached_counts-0.2.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file django_cached_counts-0.2.1.tar.gz.

File metadata

  • Download URL: django_cached_counts-0.2.1.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for django_cached_counts-0.2.1.tar.gz
Algorithm Hash digest
SHA256 377bdcc796147019dabf3afa7401f29b66e9068a92c6acdf83ff8d6149057017
MD5 15134a62a32b091f018e53cfc485e90d
BLAKE2b-256 2c82da01d59238c594e7142660bd2737db3a24a6a39b7bcc20bb7ff42c0b09e4

See more details on using hashes here.

File details

Details for the file django_cached_counts-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cached_counts-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fb586df406d54c3e877f6a30787ea3875270955ff959bee9620932424e1349ec
MD5 4d4d885353e11752abef107b79d39421
BLAKE2b-256 41b4fe8c73a61d116aba3d4256a1254c0865f6e4d90ed928011300f799bb13a2

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