Skip to content

Instantly share code, notes, and snippets.

@loic
Created August 21, 2013 07:13
Show Gist options
  • Select an option

  • Save loic/6291212 to your computer and use it in GitHub Desktop.

Select an option

Save loic/6291212 to your computer and use it in GitHub Desktop.
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 836d394..3b60aa6 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -48,6 +48,12 @@ class QuerySet(object):
"""
def __init__(self, model=None, query=None, using=None):
+ if hasattr(model, 'all'):
+ queryset = model.all()
+ model = queryset.model
+ query = queryset.query
+ using = queryset.using
+
self.model = model
self._db = using
self.query = query or sql.Query(self.model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment