This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A Django utility that makes it simple to write DRY queryset methods.

Warning

dj-queryset-manager only works with Django versions 1.2 through 1.6.

In Django 1.7 it has been superseded by QuerySet.as_manager(). See the docs.

Usage

  1. Create a manager class that inherit the QuerySetManager
  2. Decorate your filter methods with queryset_method. These methods receive a queryset instead of a manager as the first argument.
from dj_queryset_manager import QuerySetManager, queryset_method

class MyManager(QuerySetManager):
    @queryset_method
    def by_slug(queryset, slug):
        return queryset.filter(slug=slug)

    @queryset_method
    def filter(queryset, *args, **kwargs):
        return super(type(queryset), queryset).filter(*args, **kwargs)

For reference, here is a standard implementation:

from django.db.models import Manager
from django.db.models.query import QuerySet

class MyQuerySet(QuerySet):
    def by_slug(self, slug):
        return self.filter(slug=slug)

    def filter(self, *args, **kwargs):
        return super(MyQuerySet, self).filter(*args, **kwargs)


class MyManager(Manager):
    def get_query_set(self): # Better remember the arguments to QuerySet
        QuerySet(self.model, using=self._db)

    def get_queryset(self): # And don't forget about Django 1.6
        return self.get_query_set()

    def by_slug(self, *args, **kwargs):  # Enjoy this duplicate signature
        return self.get_queryset().filter(*args, **kwargs)

Mix-in

Some third-party apps ship managers as part of their API. If you need to extend any existing manager, use the QuerySetManagerMixin. This example uses the InheritanceManager from django-model-utils.

from model_utils.managers import InheritanceManager
from dj_queryset_manager import QuerySetManagerMixin, queryset_method

class MyInheritanceManager(QuerySetManagerMixin, InheritanceManager):
    @queryset_method
    def by_slug(queryset, slug):
        return queryset.filter(slug=slug)

Installation

$ pip install dj-queryset-manager
Release History

Release History

0.1.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dj-queryset-manager-0.1.3.tar.gz (3.6 kB) Copy SHA256 Checksum SHA256 Source Jun 28, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting