Commits

João Pedro Francese committed 569927d

Added ExcludeManager, a generic manager.

Comments (0)

Files changed (1)

inoa/models/managers.py

         super(FilterManager, self).__init__()
         self.args = args
         self.kwargs = kwargs
+
+class ExcludeManager(models.Manager):
+    """
+    A Manager whose querysets will filter the object by default.
+    Parameters passed in the constructor will be used directly in exclude().)
+    """
+    def get_query_set(self):
+        return super(ExcludeManager, self).get_query_set().exclude(*self.args, **self.kwargs)
+
+    def __init__(self, *args, **kwargs):
+        super(ExcludeManager, self).__init__()
+        self.args = args
+        self.kwargs = kwargs