Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Python 2.6 compatibility for #19385

  • Loading branch information...
commit 9572a3992b3f92ef6c77f51c44497e18d168a30c 1 parent 9777442
Anssi Kääriäinen akaariai authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 django/db/models/fields/related.py
10 django/db/models/fields/related.py
View
@@ -295,8 +295,9 @@ def __get__(self, instance, instance_type=None):
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 get_prefetch_queryset(self, instances):
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]),
Please sign in to comment.
Something went wrong with that request. Please try again.