Skip to content

Instantly share code, notes, and snippets.

diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index 86ddd3c..78c9770 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -67,7 +67,7 @@ class MigrationAutodetector(object):
model_state = self.to_state.models[app_label, model_name]
# Are there any relationships out from this model? if so, punt it to the next phase.
related_fields = []
- for field in new_app_cache.get_model(app_label, model_name)._meta.fields:
+ for field in new_app_cache.get_model(app_label, model_name)._meta.local_fields:
14:30 loic84: ping akaariai_
14:32 akaariai_: loic84: hi
14:32 loic84: akaariai_: hey, just spotted your comment on #21410.
14:32 ticketbot: https://code.djangoproject.com/ticket/21410
14:34 bouke has joined ([email protected])
14:34 loic84: can you think of way to express the multicolumn lookups with an example? I'd like to add a test case for it.
14:34 bouke: mYk: there appears to be a problem with the autoreloader on kqueue and PY3 -> https://github.com/django/django/blob/master/django/utils/autoreload.py#L173 bufsize is not a valid param on PY3
14:36 akaariai_: loic84: hmmh, not sure how to do that. Actually, if you give fk__in=instances in 1.6 it might be that multicolumn lookups are never involved
14:36 akaariai_: unless you have heavily modified FK field written in your project
14:37 bouke: mYk: refs #21420
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 3c71fa2..063b9f2 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -185,6 +185,7 @@ def kqueue_code_changed():
kqueue.control([make_kevent(watcher)], 0)
def update_watch(sender=None, **kwargs):
+ print("update_watch")
watcher.write(b'.')
@loic
loic / foo.diff
Last active December 29, 2015 18:09
diff --git a/django/core/exceptions.py b/django/core/exceptions.py
index 62c4d0b..418eaab 100644
--- a/django/core/exceptions.py
+++ b/django/core/exceptions.py
@@ -3,6 +3,7 @@ Global Django exception and warning classes.
"""
from functools import reduce
import operator
+import copy
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 7f30b0e..faccda1 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -693,6 +693,7 @@ class FormsTestCase(TestCase):
self.add_error('password1', 'Forbidden value 2.')
if self.cleaned_data.get('password2') == 'FORBIDDEN_VALUE2':
self.add_error('password2', 'Forbidden value 2.')
+ raise ValidationError("I'm a non field error.")
@loic
loic / foo.diff
Last active December 29, 2015 11:59
diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt
index 77f2e78..62e2294 100644
--- a/docs/ref/models/relations.txt
+++ b/docs/ref/models/relations.txt
@@ -112,13 +112,13 @@ Related objects reference
.. versionchanged 1.7::
- This method accepts a ``bulk`` argument. When ``bulk=False``,
- ``QuerySet.update()`` is replaced by multiple calls to ``Model.save()``,
diff --git a/docs/releases/1.6.1.txt b/docs/releases/1.6.1.txt
index 128a2e9..5c9bd1e 100644
--- a/docs/releases/1.6.1.txt
+++ b/docs/releases/1.6.1.txt
@@ -12,3 +12,6 @@ Bug fixes
=========
* Fixed ``BCryptSHA256PasswordHasher`` with py-bcrypt and Python 3 (#21398).
+* Fixed a regression that prevented a ``ForeignKey`` with a hidden reverse
+ manager (``related_name`` ending with '+') from being used as a lookup for
diff --git a/django/db/models/base.py b/django/db/models/base.py
index ce3f095..1d3bb12 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -360,12 +360,12 @@ class Model(six.with_metaclass(ModelBase)):
# The reason for the kwargs check is that standard iterator passes in by
# args, and instantiation for iteration is 33% faster.
args_len = len(args)
- if args_len > len(self._meta.concrete_fields):
+ if args_len > len(self._meta.fields):
diff --git a/django/db/models/base.py b/django/db/models/base.py
index a2eee60..3515569 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -333,12 +333,12 @@ class Model(six.with_metaclass(ModelBase)):
# The reason for the kwargs check is that standard iterator passes in by
# args, and instantiation for iteration is 33% faster.
args_len = len(args)
- if args_len > len(self._meta.concrete_fields):
+ if args_len > len(self._meta.fields):
@loic
loic / foo.diff
Last active December 27, 2015 20:09
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 6299b20..577f503 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -268,7 +268,7 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
rel_obj_attr = self.field.get_foreign_related_value
instance_attr = self.field.get_local_related_value
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
- query = {'%s__in' % self.field.related_query_name(): instances}
+ query = {'%s__in' % self.field.related_field.name: set([instance_attr(i)[0] for i in instances])}