Skip to main content

ChainableManager for Django Models

Allows chaining of custom model Manager methods, without jumping through QuerySet hoops.

Installing

Simply install the package using pip:

pip install django-chainable-manager

Using

Create a Manager that extends chainablemanager.ChainableManager:

from django.db import models
from chainablemanager.manager import ChainableManager

class PostManager(ChainableManager):
    class QuerySetMixin(object):
        def published(self):
            return self.filter(publish_date__gte=datetime.date.today())

        def written_by(self, user):
            return self.filter(author=user)

class Post(models.Model):
    title = models.CharField(max_length=255)
    content = models.TextField()
    publish_date = models.DateField()
    author = models.ForeignKey('auth.User')

    objects = PostManager()

Now use it where ever you need it:

from .models import Post

my_published_posts = Post.objects.written_by(request.user).published()

Metadata

Release files for django-chainable-manager 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-chainable-manager 0.5.0
File Size Uploaded Provenance Actions
django-chainable-manager-0.5.0.tar.gz 3.7 kB Without provenance Details for django-chainable-manager-0.5.0.tar.gz

Release files / django-chainable-manager-0.5.0.tar.gz

Download URL django-chainable-manager-0.5.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
14ee56784f3985566e0be48cba1fbc985e392b1ee339787c23f9041ccc150230
BLAKE2b-256 checksum
How to use checksums
a2040fc558e70f5b8a0287f5162faf67e9ee48898cb96c7a88a14ddf75cfc6e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-chainable-manager 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page