Skip to content

Instantly share code, notes, and snippets.

@loic
loic / foo.diff
Last active August 29, 2015 13:58
index 1bb64c9..253f382 100644
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -4,8 +4,10 @@ from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
from django.db import connection
from django.db.models import Prefetch
+from django.db.models.query import get_prefetcher
from django.test import TestCase, override_settings
from django.utils import six
diff --git a/tests/runtests.py b/tests/runtests.py
index e852346..0506532 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -19,6 +19,15 @@ from django.utils import six
warnings.simplefilter("default", RemovedInDjango19Warning)
warnings.simplefilter("default", RemovedInDjango20Warning)
+
+import traceback
diff --git a/django/db/models/base.py b/django/db/models/base.py
index a0f43de..a6b5bb0 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -648,23 +648,25 @@ class Model(six.with_metaclass(ModelBase)):
"""
meta = cls._meta
for parent, field in meta.parents.items():
+ self._save_parents(cls=parent, using=using, update_fields=update_fields)
+
@loic
loic / foo.diff
Last active August 29, 2015 14:00
diff --git a/django/db/models/base.py b/django/db/models/base.py
index a0f43de..d481e13 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -648,23 +648,25 @@ class Model(six.with_metaclass(ModelBase)):
"""
meta = cls._meta
for parent, field in meta.parents.items():
+ self._save_parents(cls=parent, using=using, update_fields=update_fields)
+
diff --git a/mezzanine/generic/fields.py b/mezzanine/generic/fields.py
index 8d8dd94..e95de37 100644
--- a/mezzanine/generic/fields.py
+++ b/mezzanine/generic/fields.py
@@ -134,6 +134,12 @@ class BaseGenericRelation(GenericRelation):
"""
pass
+ def value_from_object(self, obj):
+ """
04:52 cramm: so, I think the patch that gives .values() the ability to specify aliases, e.g. values(foo='field__at_the_end_of_a_chain__of__related_models') is in good shape
04:56 cramm: what I'm still fighting against is to get chaining of values(alias=...).aggregate(expression involving alias) and values(alias=...).annotate(expression involving alias) to work
04:58 cramm: but a good group of other QS chaining constructs do work: https://github.com/django/django/pull/2510/files#diff-db5fb8fdfbba5c6ac7595dd636d9b558R254
04:58 edbaffei has left IRC (Quit: edbaffei)
04:59 cramm: do you gouys whing it would be worthwhile to commit^Wask for review this in two parts? the one that is working now and the other once I can tame it and/or get some help?
05:01 jkocherhans has left IRC (Quit: Textual IRC Client: www.textualapp.com)
05:07 dlogs has joined (~dlogs@46.38.245.213)
05:09 ojii has left IRC (Ping timeout: 256 seconds)
05:20 tonebot has left IRC (Remote host closed the connection)
05:20 tonebot has joined (~node
diff --git a/django/contrib/gis/tests/tests.py b/django/contrib/gis/tests/tests.py
index cc52d24..540d495 100644
--- a/django/contrib/gis/tests/tests.py
+++ b/django/contrib/gis/tests/tests.py
@@ -16,7 +16,7 @@ except ImproperlyConfigured as e:
# an ImportError into an ImproperlyConfigured.
# Here, we make sure we're only catching this specific case and not another
# ImproperlyConfigured one.
- if e.args and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
+ if e.args and e.args[0] and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
diff --git a/django/contrib/gis/tests/tests.py b/django/contrib/gis/tests/tests.py
index cc52d24..540d495 100644
--- a/django/contrib/gis/tests/tests.py
+++ b/django/contrib/gis/tests/tests.py
@@ -16,7 +16,7 @@ except ImproperlyConfigured as e:
# an ImportError into an ImproperlyConfigured.
# Here, we make sure we're only catching this specific case and not another
# ImproperlyConfigured one.
- if e.args and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
+ if e.args and e.args[0] and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py
index 6732e45..41fb896 100644
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -508,6 +508,11 @@ class CustomPrefetchTests(TestCase):
self.assertEqual(lst2[0].houses_lst[0].rooms_lst[1], self.room1_2)
self.assertEqual(len(lst2[1].houses_lst), 0)
+ # Aymeric's regression
+ with self.assertNumQueries(2):
django-admin.py test gallery