# Path: django_toolkit/db/models.py
# class QuerySetManager(models.Manager):
#     """
#     @see http://djangosnippets.org/snippets/734/
#     @see http://hunterford.me/django-custom-model-manager-chaining/
#     """
#     def get_queryset(self):
#         return self.model.QuerySet(self.model)
# 
#     def __getattr__(self, name, *args):
#         if name.startswith('_'):
#             raise AttributeError
#         return getattr(self.get_queryset(), name, *args)


from django.db import models
from django.db.models.query import QuerySet
from django_toolkit.db.models import QuerySetManager


class ModelWithChainedQuerySet(models.Model):
    foo = models.BooleanField(default=False)
    bar = models.BooleanField(default=False)

    objects = QuerySetManager()

    def __unicode__(self):
        return u'%s' % self.pk

    class QuerySet(QuerySet):

        def is_foo(self):
            return self.filter(foo=True)

        def is_bar(self):
            return self.filter(bar=True)

        def is_not_foo(self):
            return self.filter(foo=False)

        def is_not_bar(self):

# Path: django_toolkit/db/models.py
# class QuerySetManager(models.Manager):
#     """
#     @see http://djangosnippets.org/snippets/734/
#     @see http://hunterford.me/django-custom-model-manager-chaining/
#     """
#     def get_queryset(self):
#         return self.model.QuerySet(self.model)
# 
#     def __getattr__(self, name, *args):
#         if name.startswith('_'):
#             raise AttributeError
#         return getattr(self.get_queryset(), name, *args)


# Path: django_toolkit/tests/testapp/models.py
from django.db import models
from django.db.models.query import QuerySet
from django_toolkit.db.models import QuerySetManager



class ModelWithChainedQuerySet(models.Model):
    foo = models.BooleanField(default=False)
    bar = models.BooleanField(default=False)

    objects = QuerySetManager()

    def __unicode__(self):
        return u'%s' % self.pk

    class QuerySet(QuerySet):

        def is_foo(self):
            return self.filter(foo=True)

        def is_bar(self):
            return self.filter(bar=True)

        def is_not_foo(self):
            return self.filter(foo=False)

        def is_not_bar(self):

            return self.filter(bar=False)