Skip to content

Instantly share code, notes, and snippets.

@loic
loic / foo.diff
Last active January 4, 2016 03:19
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 4a080e9..fa1e870 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -190,10 +190,9 @@ class BaseManager(six.with_metaclass(RenameManagerMethods)):
# understanding of how this comes into play.
return self.get_queryset()
-Manager = BaseManager.from_queryset(QuerySet, class_name='Manager')
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 4a080e9..24f9d95 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -196,6 +196,14 @@ Manager = BaseManager.from_queryset(QuerySet, class_name='Manager')
Manager.__module__ = 'django.db.models.manager'
+class CustomQuerySet(QuerySet):
+ pass
# encoding: utf8
from django.db import models, migrations
import datetime
class Migration(migrations.Migration):
dependencies = [
(u'testapp', u'some_other_one'),
]
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 82e7725..a874b3a 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -173,21 +173,24 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri
return self.related.model._base_manager.db_manager(hints=hints)
def get_prefetch_queryset(self, instances, queryset=None):
- if queryset is not None:
- raise ValueError("Custom queryset can't be used for this lookup.")
loic84: (TODO: this nomenclature is confusing, can we invent something better) "lookup operator"?
13:57 akaariai: loic84: which part does it refer to in relatedfield__datefield__year__gt=2013?
13:57 loic84: __gt
13:57 akaariai: ok, sounds good
13:58 akaariai: the relatedfield__datefield__year__gt is lookup, relatedfield__datefield is fields part, year is what?
13:58 loic84: 2013 could be the "lookup value"
13:58 akaariai: loic84: yes
13:59 loic84: hum year...
14:00 loic84: maybe "year__gt" is the operator?
14:00 akaariai: loic84: ok, gt is final operator? (Implemented by Lookup class...)
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index eede6fb..eed88a0 100644
--- a/django/contrib/staticfiles/finders.py
+++ b/django/contrib/staticfiles/finders.py
@@ -57,7 +57,7 @@ class FileSystemFinder(BaseFinder):
prefix, root = root
else:
prefix = ''
- if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
+ if settings.STATIC_ROOT and os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index eede6fb..eed88a0 100644
--- a/django/contrib/staticfiles/finders.py
+++ b/django/contrib/staticfiles/finders.py
@@ -57,7 +57,7 @@ class FileSystemFinder(BaseFinder):
prefix, root = root
else:
prefix = ''
- if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
+ if settings.STATIC_ROOT and os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
diff --git a/django/forms/utils.py b/django/forms/utils.py
index 3582384..4d44d28 100644
--- a/django/forms/utils.py
+++ b/django/forms/utils.py
@@ -127,6 +127,10 @@ class ErrorList(UserList):
return list(error)[0]
return force_text(error)
+ @classmethod
+ def __instancecheck__(cls, instance):
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 5f24bf0..d060f29 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -89,6 +89,8 @@ def create_permissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kw
# Find all the Permissions that have a content_type for a model we're
# looking for. We don't need to check for codenames since we already have
# a list of the ones we're going to create.
+ print ctypes
+ print len(ctypes)
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 5f24bf0..8cc14894 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -89,6 +89,7 @@ def create_permissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kw
# Find all the Permissions that have a content_type for a model we're
# looking for. We don't need to check for codenames since we already have
# a list of the ones we're going to create.
+ print len(ctypes)
all_perms = set(auth_app.Permission.objects.using(db).filter(