Ticket #22268: 22268.diff

File 22268.diff, 1.1 KB (added by ANUBHAV JOSHI, 7 years ago)
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index 2800361..194fc9d 100644
    a b from django.db.models.constants import LOOKUP_SEP 
    1717from django.db.models.aggregates import refs_aggregate
    1818from django.db.models.expressions import ExpressionNode
    1919from django.db.models.fields import FieldDoesNotExist
     20from django.db.models.fields.related import ManyToManyRel
    2021from django.db.models.query_utils import Q
    2122from django.db.models.related import PathInfo
    2223from django.db.models.sql import aggregates as base_aggregates_module
    class Query(object): 
    16061607                targets, final_alias, joins = self.trim_joins(targets, joins, path)
    16071608                for target in targets:
    16081609                    self.select.append(SelectInfo((final_alias, target.column), target))
     1610                if isinstance(field.rel, ManyToManyRel) and 'id' not in field_names:
     1611                    field_names.append('id')
    16091612        except MultiJoin:
    16101613            raise FieldError("Invalid field name: '%s'" % name)
    16111614        except FieldError:
Back to Top