I temporarily have corrected this by extracting the first occurrence of
the name column:
Note the line "if column not in model_init_field_names:"
{{{
class MyRawQuerySet(RawQuerySet):
def __iter__(self):
# Mapping of attrnames to row column positions. Used for
constructing
# the model using kwargs, needed when not all model's fields are
present
# in the query.
model_init_field_names = {}
# A list of tuples of (column name, column position). Used for
# annotation fields.
annotation_fields = []
# Cache some things for performance reasons outside the loop.
db = self.db
compiler = connections[db].ops.compiler('SQLCompiler')(
self.query, connections[db], db
)
need_resolv_columns = hasattr(compiler, 'resolve_columns')
query = iter(self.query)
try:
# Find out which columns are model's fields, and which ones
should be
# annotated to the model.
for pos, column in enumerate(self.columns):
if column not in model_init_field_names:
if column in self.model_fields:
model_init_field_names[self.model_fields[column].attname] = pos
else:
annotation_fields.append((column, pos))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23928>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
It isn't clear how to reproduce the error you are seeing from the
description. Could you post example models and the raw query that is
causing the problem for you. I'll close this needsinfo, please reopen when
you provide the additional information.
--
Ticket URL: <https://code.djangoproject.com/ticket/23928#comment:1>