Python 2.6 compatibility for #19385
This commit is contained in:
parent
97774429ae
commit
9572a3992b
|
@ -295,8 +295,9 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
|
||||||
if None in val:
|
if None in val:
|
||||||
rel_obj = None
|
rel_obj = None
|
||||||
else:
|
else:
|
||||||
params = {rh_field.attname: getattr(instance, lh_field.attname)
|
params = dict(
|
||||||
for lh_field, rh_field in self.field.related_fields}
|
(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))
|
params.update(self.field.get_extra_descriptor_filter(instance))
|
||||||
qs = self.get_query_set(instance=instance)
|
qs = self.get_query_set(instance=instance)
|
||||||
# Assuming the database enforces foreign keys, this won't fail.
|
# 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
|
join_table = self.through._meta.db_table
|
||||||
connection = connections[db]
|
connection = connections[db]
|
||||||
qn = connection.ops.quote_name
|
qn = connection.ops.quote_name
|
||||||
qs = qs.extra(select={'_prefetch_related_val_%s' % f.attname:
|
qs = qs.extra(select=dict(
|
||||||
'%s.%s' % (qn(join_table), qn(f.column)) for f in fk.local_related_fields})
|
('_prefetch_related_val_%s' % f.attname,
|
||||||
|
'%s.%s' % (qn(join_table), qn(f.column))) for f in fk.local_related_fields))
|
||||||
return (qs,
|
return (qs,
|
||||||
lambda result: tuple([getattr(result, '_prefetch_related_val_%s' % f.attname) for f in fk.local_related_fields]),
|
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]),
|
lambda inst: tuple([getattr(inst, f.attname) for f in fk.foreign_related_fields]),
|
||||||
|
|
Loading…
Reference in New Issue