From 9572a3992b3f92ef6c77f51c44497e18d168a30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sun, 24 Mar 2013 19:00:24 +0200 Subject: [PATCH] Python 2.6 compatibility for #19385 --- django/db/models/fields/related.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index b7d68e9ce3..5b2f35bb08 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -295,8 +295,9 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec if None in val: rel_obj = None else: - params = {rh_field.attname: getattr(instance, lh_field.attname) - for lh_field, rh_field in self.field.related_fields} + params = dict( + (rh_field.attname, getattr(instance, lh_field.attname)) + for lh_field, rh_field in self.field.related_fields) params.update(self.field.get_extra_descriptor_filter(instance)) qs = self.get_query_set(instance=instance) # Assuming the database enforces foreign keys, this won't fail. @@ -556,8 +557,9 @@ def create_many_related_manager(superclass, rel): join_table = self.through._meta.db_table connection = connections[db] qn = connection.ops.quote_name - qs = qs.extra(select={'_prefetch_related_val_%s' % f.attname: - '%s.%s' % (qn(join_table), qn(f.column)) for f in fk.local_related_fields}) + qs = qs.extra(select=dict( + ('_prefetch_related_val_%s' % f.attname, + '%s.%s' % (qn(join_table), qn(f.column))) for f in fk.local_related_fields)) return (qs, lambda result: tuple([getattr(result, '_prefetch_related_val_%s' % f.attname) for f in fk.local_related_fields]), lambda inst: tuple([getattr(inst, f.attname) for f in fk.foreign_related_fields]),