Created
May 26, 2011 22:40
-
-
Save seanmonstar/994265 to your computer and use it in GitHub Desktop.
QuerySetManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuerySetManager(models.Manager): | |
def get_query_set(self): | |
return self.QuerySet(self.model) | |
def __getattr__(self, attr, *args): | |
return getattr(self.get_query_set(), attr, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PackagesManager(QuerySetManager): | |
class QuerySet(QuerySet): | |
def active(self): | |
pass | |
def addons(self): | |
pass | |
def libraries(self): | |
pass | |
def recently_active(self): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package.objects.active().libraries().recently_active().filter(author=1) |
possibly. that is up to how Django executes QuerySets. basically, this just easily adds the methods we add to the manager to be chainable from the QuerySet as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
would filter by author before recently active make the last one quicker?